In my GridView I have a column being bound to MyValue. There's 5 different "ranges" MyValue can fall into, and depending on what it is the background changes colors.
The ranges are as follows: >= 8, >= 4 && < 8, >= -4 && < 4, >= -8 && < -4, and finally < 8.
Here's my current code, though I've tried many different iterations of this trying to get it to work.
<telerik:GridViewDataColumn Header="MyValue" DataMemberBinding="{Binding MyValue}">
<telerik:GridViewDataColumn.CellTemplateSelector>
<telerik:ConditionalDataTemplateSelector>
<telerik:DataTemplateRule Condition="MyValue >= 8">
<DataTemplate>
<Border Background="Red" BorderBrush="Black" BorderThickness="1">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding MyValue}" Foreground="White" />
</Border>
</DataTemplate>
</telerik:DataTemplateRule>
<telerik:DataTemplateRule Condition="MyValue >= 4">
<DataTemplate>
<Border Background="Yellow" BorderBrush="Black" BorderThickness="1">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding MyValue}" Foreground="Black" />
</Border>
</DataTemplate>
</telerik:DataTemplateRule>
<telerik:DataTemplateRule Condition="MyValue >= (4)">
<DataTemplate>
<Border Background="Green" BorderBrush="Black" BorderThickness="1">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding MyValue}" Foreground="White" />
</Border>
</DataTemplate>
</telerik:DataTemplateRule>
<telerik:DataTemplateRule Condition="MyValue >= (8)">
<DataTemplate>
<Border Background="Yellow" BorderBrush="Black" BorderThickness="1">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding MyValue}" Foreground="Black" />
</Border>
</DataTemplate>
</telerik:DataTemplateRule>
<telerik:DataTemplateRule Condition="MyValue < (8)">
<DataTemplate>
<Border Background="Red" BorderBrush="Black" BorderThickness="1">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding MyValue}" Foreground="White" />
</Border>
</DataTemplate>
</telerik:DataTemplateRule>
</telerik:ConditionalDataTemplateSelector>
</telerik:GridViewDataColumn.CellTemplateSelector>
</telerik:GridViewDataColumn>
In this version you can see I tried doing negatives as (N), but I've also tried -N and that didn't work at all. What's happening is that only some of the rules are working, and the -4 to 4 rule never works, the background is never green. It's almost always red, and sometimes it'll turn yellow, but only for the 4 to 8 range, never for the -8 to -4 range. Any ideas what I'm doing wrong? Thanks
The ranges are as follows: >= 8, >= 4 && < 8, >= -4 && < 4, >= -8 && < -4, and finally < 8.
Here's my current code, though I've tried many different iterations of this trying to get it to work.
<telerik:GridViewDataColumn Header="MyValue" DataMemberBinding="{Binding MyValue}">
<telerik:GridViewDataColumn.CellTemplateSelector>
<telerik:ConditionalDataTemplateSelector>
<telerik:DataTemplateRule Condition="MyValue >= 8">
<DataTemplate>
<Border Background="Red" BorderBrush="Black" BorderThickness="1">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding MyValue}" Foreground="White" />
</Border>
</DataTemplate>
</telerik:DataTemplateRule>
<telerik:DataTemplateRule Condition="MyValue >= 4">
<DataTemplate>
<Border Background="Yellow" BorderBrush="Black" BorderThickness="1">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding MyValue}" Foreground="Black" />
</Border>
</DataTemplate>
</telerik:DataTemplateRule>
<telerik:DataTemplateRule Condition="MyValue >= (4)">
<DataTemplate>
<Border Background="Green" BorderBrush="Black" BorderThickness="1">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding MyValue}" Foreground="White" />
</Border>
</DataTemplate>
</telerik:DataTemplateRule>
<telerik:DataTemplateRule Condition="MyValue >= (8)">
<DataTemplate>
<Border Background="Yellow" BorderBrush="Black" BorderThickness="1">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding MyValue}" Foreground="Black" />
</Border>
</DataTemplate>
</telerik:DataTemplateRule>
<telerik:DataTemplateRule Condition="MyValue < (8)">
<DataTemplate>
<Border Background="Red" BorderBrush="Black" BorderThickness="1">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding MyValue}" Foreground="White" />
</Border>
</DataTemplate>
</telerik:DataTemplateRule>
</telerik:ConditionalDataTemplateSelector>
</telerik:GridViewDataColumn.CellTemplateSelector>
</telerik:GridViewDataColumn>
In this version you can see I tried doing negatives as (N), but I've also tried -N and that didn't work at all. What's happening is that only some of the rules are working, and the -4 to 4 rule never works, the background is never green. It's almost always red, and sometimes it'll turn yellow, but only for the 4 to 8 range, never for the -8 to -4 range. Any ideas what I'm doing wrong? Thanks