0

I have a MultiTrigger that I use to color the values of my DataGrid control. This trigger was working fine until recently when I discovered the color no longer worked. I looked at the database and discovered that blank spaces were trailing my value and thus my trigger comparison of the value would always fail.

I was wondering if there is a stringformat or a trim function that I can do inline with my xaml so that I don't have to write a converter class to just do "value.trim() return value"

Here is my xaml:

<MultiDataTrigger>
    <MultiDataTrigger.Conditions>
        <!-- this is the actual grid column element binding -->
        <Condition Binding="{Binding FieldName, RelativeSource={RelativeSource Self}}" Value="SocketState"/>
        <!-- this checks the value on the element referenced ^here-->
        <Condition Binding="{Binding SocketState}" Value="Connected" />
    </MultiDataTrigger.Conditions>

    <Setter Property="Background" Value="{StaticResource YellowGreenGradientBrush}"/>
</MultiDataTrigger>
Anatoliy Nikolaev
  • 22,370
  • 15
  • 69
  • 68
TWood
  • 2,563
  • 8
  • 36
  • 58
  • Shouldn't you first work out why your database values have developed trailing spaces, fix the root issue and cleanse the data? – Ben Mar 24 '12 at 18:28
  • Yeah, I agree. That's what I should/will do. But i'm not the only dev working on the code. I'll submit it to the fix list and my workaround will keep me from waiting on someone else. – TWood Mar 24 '12 at 18:31

1 Answers1

0

Fixed my issue by trimming in my sql view. No wpf code change necessary.

TWood
  • 2,563
  • 8
  • 36
  • 58