The steps are:

1.       Change the column XAML for “Trade” to use cell template:

                <data:DataGridTemplateColumn Header="Trade" Width="80">



                            <TextBlock TextAlignment="Right" VerticalAlignment="Center"  FontSize="12" Text="{Binding last}" Foreground ="{Binding lastForegroundColor}"></TextBlock>





2.       Adding a function to determine the color of row:


        private String GetLastForegroundColor(string last, string previousClose)


            if (Convert.ToDouble(last) > Convert.ToDouble(previousClose))


                return "Green";


            else if (Convert.ToDouble(last) < Convert.ToDouble(previousClose))


                return "Red";




                return "Black";




        Adding the following line into the DisplayInDataGrid function and new OneStock section.

lastForegroundColor = GetLastForegroundColor(g.Element("Last").Value, g.Element("PreviousClose").Value)


3.       Ctrl-F5 and we should see the “Trade” column show either green, red depending on the current stock price.