locked
Changing Dynamic Textblock foreground in Datagrid DataTemplate by using IValueConverter

    Question

  • Hi there,

    Yesterday I had tried to post 2 posts related to this issue. However, my posts are not posted.
    As I need to solve this out by today for tomorrow performance. Please help.

    Below this link I had upload all related print screen of my files.
    http://picasaweb.google.com/yamino1983/Datagrid?feat=directlink#

    I'm trying to create a Date row by using Datagrid. In the datagrid, I had created two textblocks inside the DataTemplate. There are 7 columns and each column has the same DataTemplate. One Textblock showing the day and another one showing the date. And User can click an arrow button either to forward or backward the date.

    On the first loading, the first column will show the Today date and the text foreground is in blue. when user click forward, the first column date will become the date before Today date and the second column will be the Today date. Now, since the values have been changed, and the first column is not Today date anymore, the text foreground has to be black, and the second column which showing today date has to be blue.

    I had tried switching 2 CellStyle for this but it returns error in Silverlight 2 Beta 2. Therefore, I had changed to use IValueConverter which I had found in this forum. I had bind the IValueConverter in the Textblock like this as I only want to change the foreground color.
    <TextBlock x:Name="lblCurrentDay"  Text="{Binding CurrentDay}" Foreground="{Binding Converter={StaticResource mc}}"></TextBlock>
    <TextBlock x:Name="lblCurrentDate" Text="{Binding CurrentDate}" Foreground="{Binding Converter={StaticResource mc}}"></TextBlock>

    and it return all the values in the datagrid. I had the print screen for this. Now, I don't know how should I do to get the value one by one out to check whether it is today date or not? I got stuck here. I can't do value.CurrentDate or value.Day1 or etc......I had spent one whole day to make this work. Anyone please help or is there any better solutions? Thanks!!!

    Wednesday, May 27, 2009 8:35 PM

Answers

All replies