By default, after datagrid bound data source, in a column after editing interface, the data will not be updated to memory object. If there is a command to get the currently selected row (memory objects) found that the data is not updated over on the same line.
Solution:
In the column's binding properties plus UpdateSourceTrigger, the following example XAML
-
<DataGrid Name="dgProducts" IsReadOnly="False" CanUserAddRows="False" Grid.Row="1"
-
CanUserDeleteRows=
"False"
AutoGenerateColumns=
"False"
Hyperlink.Click=
"dgProducts_Click">
-
<DataGrid.Columns>
-
<DataGridTextColumn Header="产品编码" IsReadOnly="True" Binding="{Binding Path=ProductNO, Mode=TwoWay}"/>
-
<DataGridTextColumn Header="产品名称" IsReadOnly="True" Width="150" Binding="{Binding Path=ProductName, Mode=TwoWay}"/>
-
<DataGridTextColumn Header="规格型号" IsReadOnly="True" Width="150" Binding="{Binding Path=ProductSpec, Mode=TwoWay}"/>
-
<DataGridTextColumn Header="生产数量" IsReadOnly="False" Binding="{Binding Path=MakeNums, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
-
<DataGridHyperlinkColumn Header="操作" Width="*" Binding="{Binding Path=PCmd}" />
-
</DataGrid.Columns>
-
-
</DataGrid>
When such real-time editing Datagrid cell data will immediately update the value of the data source.
UpdateSourceTrigger enumeration details see
http://msdn.microsoft.com/zh-cn/library/system.windows.data.updatesourcetrigger(v=vs.95).aspx