Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Databinding and cascading Converters?

i wonder if it is possible to cascade converters when using wpf databinding. e.g. something like

<SomeControl Visibility="{Binding Path=SomeProperty, Converter={StaticResource firstConverter}, Converter={StaticResource secondConverter}}"/>

is it possible at all or do i have to create a custom converter that combines the functionality of converter A and B?

like image 858
Joachim Kerschbaumer Avatar asked Oct 17 '08 07:10

Joachim Kerschbaumer


1 Answers

You may be looking for a solution similar to Josh Smith's "Piping Value Converters".

In his article, he presents the following:

<local:ValueConverterGroup x:Key="statusDisplayNameGroup">
  <local:IntegerStringToProcessingStateConverter  />
  <local:EnumToDisplayNameConverter />
</local:ValueConverterGroup> 

And then uses the multi-value converters as follows:

<TextBlock Text="{Binding XPath=@Status, 
             Converter={StaticResource statusDisplayNameGroup}}" />

Hope this helps!

like image 133
Brad Leach Avatar answered Sep 24 '22 18:09

Brad Leach