EXtensible Application Markup Language (XAML) is a XML based markup language developed by Microsoft. It is used in several Microsoft technologies like Windows Presentation Foundation (WPF), Silverlight, WinRT, Universal Windows Platform, etc. to define the User Interface for applications.
The Convert
method converts the value from the source (usually the view model) to the target (usually a property of a control).
The ConvertBack
method converts the value from the target back to the source. It is only needed if the binding is TwoWay
or OneWayToSource
.
When a ConvertBack
is not supported, i.e. there is no one-to-one mapping between the pre-conversion value and the post-conversion value, it's common practice to have the ConvertBack
method return DependencyProperty.UnsetValue
. It's a better option than throwing an exception (e.g. NotImplementedException
) as it avoids unexpected runtime errors. Also, bindings can benefit of their FallbackValue
when DependencyProperty.UnsetValue
is returned by a converter.
All these tags produce the same result.
XAML is used in Silverlight, Windows Phone, Windows RT and UWP apps. Sharing code or converting code between these is sometimes harder than desirable due to subtle differences between the various XAML dialects. This topic strives to give an overview of these differences with a short explanation.