# Mapping Converters | WPF Controls | DevExpress Documentation

Mapping converters allow you to apply custom logic to [mapping](/WPF/119493/controls-and-libraries/scheduler/data-binding/mappings).

## Overview

Converters can change data from one type to another, translate data based on additional information, or change the format in which the data is stored. To associate a value converter with a mapping, create a class that implements the [IValueConverter](https://learn.microsoft.com/dotnet/api/system.windows.data.ivalueconverter) interface and its **Convert** and **ConvertBack** methods and specify it  in XAML using the [Mapping.Converter](/WPF/DevExpress.Xpf.Scheduling.Mapping.Converter) property.

The data is propagated back and forth between the property, default mapping method and a data source field. You can insert a converter between the property and the default mapping method, or between default mapping method and the data source field, or instead of a default mapping method. Converter position in that propagation chain is defined by the [MappingConversionBehavior](/CoreLibraries/DevExpress.XtraScheduler.MappingConversionBehavior?v=26.1) enumeration.

The following image illustrates the converter’s processing order:

![MappingConverterDiagram](/WPF/images/mappingconverterdiagram127824.png)

## How to Create a Converter

The following example implements a mapping converter that returns label colors based on enumeration values:

[View Example: Implement a Custom Mapping Converter for Color Values](https://github.com/DevExpress-Examples/wpf-scheduler-implement-custom-mapping-converter-for-color-values)

1. Implement a class with a [IValueConverter](https://learn.microsoft.com/dotnet/api/system.windows.data.ivalueconverter) interface (inherited from the [MarkupExtension](https://learn.microsoft.com/dotnet/api/system.windows.markup.markupextension) class).

- PriorityToColorConverter.cs
    - PriorityToColorConverter.vb

<section id="tabpanel_vxhWpCXFpj_tabid-csharp" role="tabpanel" data-tab="tabid-csharp">
<pre><code class="lang-csharp">class PriorityToColorConverter : MarkupExtension, IValueConverter {
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
        if (value is Priority) {
            var priorityValue = (Priority)value;
            switch (priorityValue) {
                case Priority.High:
                return Colors.Red;

                case Priority.Normal:
                return Colors.Yellow;

                case Priority.Low:
                return Colors.Green;

                default:
                return Colors.Black;
            }
        }
        return Colors.Transparent;
    }
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
        throw new NotImplementedException();
    }
    public override object ProvideValue(IServiceProvider serviceProvider) {
        return this;
    }
}
</code></pre></section>
<section id="tabpanel_vxhWpCXFpj_tabid-vb" role="tabpanel" data-tab="tabid-vb" aria-hidden="true" hidden="hidden">
<pre><code class="lang-vb">Friend Class PriorityToColorConverter
    Inherits MarkupExtension
    Implements IValueConverter

    Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.Convert
        If TypeOf value Is Priority Then
            Dim priorityValue = CType(value, Priority)
            Select Case priorityValue
                Case Priority.High
                    Return Colors.Red
                Case Priority.Normal
                    Return Colors.Yellow
                Case Priority.Low
                    Return Colors.Green
                Case Else
                    Return Colors.Black
            End Select
        End If

        Return Colors.Transparent
    End Function

    Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
        Throw New NotImplementedException()
    End Function

    Public Overrides Function ProvideValue(ByVal serviceProvider As IServiceProvider) As Object
        Return Me
    End Function
End Class
</code></pre></section>
2. Assign the converter to the label color mapping’s [Mapping.Converter](/WPF/DevExpress.Xpf.Scheduling.Mapping.Converter) property:

- MainWindow.xaml

<section id="tabpanel_vxhWpCXFpj-1_tabid-xaml" role="tabpanel" data-tab="tabid-xaml">
<pre><code class="lang-xaml">&lt;dxsch:DataSource.AppointmentLabelMappings&gt;
    &lt;dxsch:AppointmentLabelMappings 
        Color=&quot;{dxsch:Mapping FieldName=Id, 
                              ConversionBehavior=BetweenFieldAndMapping, 
                              Converter={local:PriorityToColorConverter}}&quot;                            
        Caption=&quot;Name&quot;
        ColorSavingType=&quot;ColorInstance&quot;
        Id=&quot;Id&quot;/&gt;
&lt;/dxsch:DataSource.AppointmentLabelMappings&gt;
</code></pre></section>