Change Grid row colour based on one coloum value RRS feed

  • Question

  • How to change The grid row colour based on some condition in silverlight applctaion
    In the grid, any value status="IOP" then the colour need to change to red...How can do that?

       Source.Add(New Data() With _
                    { _
                        .DateOf = e.Result(Loopcnt).ETdatedisplay,
                        .Locate = location,
                        .StatusOf = Status,
                        .SpeedOf = e.Result(Loopcnt).ETspeed

      TrackGrid.ItemsSource = Source
     TrackGrid.IsEnabled = True

    I tried the way I mentioned here below ...Nt Success..>requesting the help
                For i = 0 To 9
                    If TrackGrid.RowStyle.GetValue(i) = "IOP" Then
                        TrackGrid.Foreground = New SolidColorBrush(Colors.Red)
                    End If

    Thursday, March 6, 2014 1:42 PM


  • Hi,

    Silverlight datagrid exposes an event “LoadingRow”. This event Occurs after a DataGridRow is instantiated.

    Adding the event in xaml:

    <sdk:DataGrid AutoGenerateColumns="True" Height="217" 
                          Margin="4,45,0,0" Name="dataGrid1" 

    Adding the code in .cs file

    private void dataGrid1_LoadingRow(object sender, DataGridRowEventArgs e)
                Book book = e.Row.DataContext as Book;
                if (book != null)
                    double price = double.Parse(book.price);
                    if (price > 5)
                        e.Row.Background = new SolidColorBrush(Colors.Green);

    In the event handler we are highlighting the books priced more than 5.

    Any more information you can refer to the link:


    Best Wishes!

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, March 7, 2014 6:58 AM