This library contains a collection of often used converters to write a WPF based application.
The recommended way to use this library is via Nuget.
Currently supported frameworks:
Import it via:
xmlns:c="clr-namespace:NKristek.Wpf.Converters;assembly=NKristek.Wpf.Converters"
You can use a converter from this library either by using the MarkupExtension*:
<Label Content="{Binding Value}"
Visibility="{Binding Value, Converter={c:ValueNotNullToVisibilityConverter}}" />
or static instance:
<Label Content="{Binding Value}"
Visibility="{Binding Value, Converter={x:Static c:ValueNotNullToVisibilityConverter.Instance}}" />
or of course create instances in the views:
<Window.Resources>
<c:ValueNotNullToVisibilityConverter x:Key="ValueNotNullToVisibilityConverter" />
</Window.Resources>
<Label Content="{Binding Value}"
Visibility="{Binding Value, Converter={StaticResource ValueNotNullToVisibilityConverter}}" />
You can also use the ValueConverterChain
converter*, which executes the given converters in succession. Please note, that the TargetType is only correctly set, when the ValueConversionAttribute
is set on the IValueConverter
.
<c:ValueConverterChain x:Key="ValueNullToInverseBoolConverter">
<c:ValueNullToBoolConverter/>
<c:BoolToInverseBoolConverter/>
</c:ValueConverterChain>
The above use of the ValueConverterChain
would be equivalent to the ValueNullToInverseBoolConverter
.
*: Only available if target framework is >= .NET 4.0.
Bool:
Visibility:
Other:
If you find a bug feel free to open an issue. Contributions are also appreciated.