Windows.UI.Xaml.Data.Binding.Converter
July 6, 2022 · View on GitHub
-description
Gets or sets the converter object that is called by the binding engine to modify the data as it is passed between the source and target, or vice versa.
-xaml-syntax
<Binding Converter="converterReference"/>
-xaml-values
- converterReference
- converterReferenceA reference to an existing object that implements IValueConverter and functions as a converter. Typically the object is created in a ResourceDictionary and given a key, then referenced by using the {StaticResource} markup extension. For example: <Binding Converter="{StaticResource myConverter}" .../>
-remarks
Create a converter by implementing the IValueConverter interface and implementing the Convert method. That method should return an object that is of the same type as the dependency property that the binding targets, or at least a type that can be implicitly coerced or converted to the target type.
-examples
To use your converter in a binding, first create an instance of your converter class. The following example shows this as a resource in a XAML file.
[!code-xamlConverterResource]
[!code-xamlSetConverter]
[!code-csharp1]
[!code-vb1]
-see-also
XAML data binding sample, Data binding in depth b4f1-6caf-4128-a61a-4e400b149011)