开发者

Strange Behaviour in DataGrid SilverLight 3 Control

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)
            ret开发者_JS百科urn new SolidColorBrush(Colors.Red);
        else
            return new SolidColorBrush(Colors.White);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜