Tutorial by Examples

Converter between boolean and visibility. Get bool value on input and returns Visibility value. NOTE: This converter have already exists in System.Windows.Controls namespace. public sealed class BooleanToVisibilityConverter : IValueConverter { /// <summary> /// Convert bool or Nu...
Show how to create simple converter with parameter via property and then pass it in declaration. Convert bool value to Visibility. Allow invert result value by setting Inverted property to True. public class BooleanToVisibilityConverter : IValueConverter { public bool Inverted { get; set; } ...
Show how to create simple IMultiValueConverter converter and use MultiBinding in xaml. Get summ of all values passed by values array. public class AddConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { ...
Show how to create simple converter and use ConverterParameter to pass parameter to converter. Multiply value by coefficient passed in ConverterParameter. public class MultiplyConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo cult...
This converter will chain multiple converters together. public class ValueConverterGroup : List<IValueConverter>, IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return this.Aggregate(value, (current, converte...
Usually to use the converter, we have to define it as resource in the following way: <converters:SomeConverter x:Key="SomeConverter"/> It is possible to skip this step by defining a converter as MarkupExtension and implementing the method ProvideValue. The following example conve...
It is possible to pass multiple bound values as a CommandParameter using MultiBinding with a very simple IMultiValueConverter: namespace MyProject.Converters { public class Converter_MultipleCommandParameters : MarkupExtension, IMultiValueConverter { public object Convert(object...

Page 1 of 1