views:

111

answers:

0

Here is the my Xaml Code. Here I have changed the Foreground of the cell depending on the current age of the person.

<data:DataGridTemplateColumn Header="First Name" Width="150" MinWidth="150" CanUserReorder="False" SortMemberPath="FirstName">
                <data:DataGridTemplateColumn.CellTemplate>
                    <DataTemplate >
                        <TextBlock   Foreground ="{Binding Path=DateOfBirth,Mode=OneWay,Converter={StaticResource CellColor}}" Text="{Binding FirstName}" ToolTipService.ToolTip="{Binding FirstName}"  FontFamily="Arial" FontSize="11"  VerticalAlignment="Center" Margin="5,0,0,0" />
                    </DataTemplate>
                </data:DataGridTemplateColumn.CellTemplate>
            </data:DataGridTemplateColumn>
            <data:DataGridTextColumn Foreground ="{Binding Path=DateOfBirth,Mode=OneWay,Converter={StaticResource CellColor}}"  Header="Last Name" Width="150" MinWidth="150" Binding="{Binding LastName}" CanUserSort="True" IsReadOnly="True" CanUserReorder="False"/>

When I run the above code it return following Exception

AG_E_PARSER_BAD_PROPERTY_VALU

My question is that when I remove the Foreground converter from the DataGridTextColumn Column it runs fine As the Foreground converter is applied in the DataGridTemplateColumn Column which will not through excepction. But when I used same Converter to the DataGridTextColumn it throw execption why, can anyone know why is th is behaviour

thanks in advance.

Sorry Josh Einstein Here is the my return value from the converter

        if (intAge > 25)
            return new SolidColorBrush(Colors.Red);
        else
            return new SolidColorBrush(Colors.White);

related questions