WPF DataGrid - cell's new value after edit ending

后端 未结 2 2014
伪装坚强ぢ
伪装坚强ぢ 2021-01-17 16:57

In my system I need to capture and send the old and new value of a cell edit. I\'ve read that you can do this by inspecting the EditingElement of the event DataGridCellEditE

相关标签:
2条回答
  • 2021-01-17 17:08

    Try to bind into NotifyOnTargetUpdated - hope this is what you are looking for

    <DataGrid Name="datagrid" AutoGenerateColumns="False" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling">
        <DataGrid.Columns>
            <DataGridTextColumn  Header="Title" Binding="{Binding Path=Name,NotifyOnTargetUpdated=True}" Width="300">
                <DataGridTextColumn.EditingElementStyle>
                    <Style TargetType="{x:Type TextBox}">
                        <EventSetter Event="LostFocus" Handler="Qty_LostFocus" />
                        <EventSetter Event="TextChanged" Handler="TextBox_TextChanged" />
                        <EventSetter Event="Binding.TargetUpdated" Handler="DataGridTextColumn_TargetUpdated"></EventSetter>
                    </Style>
                </DataGridTextColumn.EditingElementStyle>
            </DataGridTextColumn>
        </DataGrid.Columns>
    </DataGrid>
    
    0 讨论(0)
  • 2021-01-17 17:23

    I took the approach of having my row data objects inherit from IEditableObject. I handle the updated value in the EndEdit() interface method

    0 讨论(0)
提交回复
热议问题