Tuesday, August 08, 2006

An article has just been published on code project by Josh Smith that should not escape your attention: Piping value converters in WPF.

Basically, he has written a simple class that will allow you to define a group of converters and use it during databinding like so:
    <local:ValueConverterGroup x:Key="statusForegroundGroup">
      <local:IntegerStringToProcessingStateConverter  />
      <local:ProcessingStateToColorConverter />
      <local:ColorToSolidColorBrushConverter />
    </local:
ValueConverterGroup>

and then use it like so:

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

          Foreground="{Binding XPath=@Status,
                       Converter={StaticResource statusForegroundGroup}}"
/>

This should prove very valuable indeed!

Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):