The Problem:
I spent a whole day to solve the problem with the Grid. I applied all my knowledge but with no solution. Suddenly I tried one thing, and it worked. So thought of sharing with guys. The problem was that the datagrid does not update the info after i edit. The information remains the same. Let's start from the beginning.
Create a class:
Lets create a DTO object for the DataGrid.The properties are:
public string TaskName { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public string AssignedTo { get; set; }
public string Comments { get; set; }
public string Status { get; set; }
Create the DataGrid:
<data:DataGrid x:Name="dataGrid" Grid.Row="3" Grid.ColumnSpan="3" Margin="0,-1,0,1" AutoGenerateColumns="False" >
<data:DataGrid.Columns>
<data:DataGridTemplateColumn CanUserSort="True" Header="Task Name">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding TaskName}"></TextBlock>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
<data:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox Text="{Binding TaskName }"></TextBox>
</DataTemplate>
</data:DataGridTemplateColumn.CellEditingTemplate>
</data:DataGridTemplateColumn>
<data:DataGridTemplateColumn CanUserSort="True" Header="Module Name">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding ModuleName}"></TextBlock>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
<data:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox Text="{Binding ModuleName}"/>
</DataTemplate>
</data:DataGridTemplateColumn.CellEditingTemplate>
</data:DataGridTemplateColumn>
I am leaving rest to you.

Alex ZhangPosted Feb 4, 2010, 1:18 AM
I run into the problem for a long time,still don't resolve it yet.The problem is i want to change the back ground color of a selected row in datagrid,but i don't know how to make it work.Hope you can help me. The environment is: There is a button named Green,if i click the Green button,the background color of the selected row in the datagrid will turn to Green. Thanks in advance Ascap