1

我有一个 DataGrid,我将 10 DataGridTextColumn 绑定到它。我添加了一个 CellEditEnding 来捕获编辑文本时的内容,以便我可以保存它。我想知道是否有可能只获得 CellEditEnding

<DataGridTextColumn Header="Notes" Binding="{Binding Path=Notes}".

这是数据网格

<DataGrid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="5" 
          BeginningEdit="OnBeginEdit" 
          CellEditEnding="OnEndEdit" 
          Name="dgActiveProblems" 
          CanUserAddRows="False" 
          CanUserDeleteRows="True" 
          AutoGenerateColumns="False"
          SelectionMode="Single"    
          AlternatingRowBackground="BlanchedAlmond"
          ItemContainerStyle="{StaticResource NormalRow}"
          IsManipulationEnabled="True" >
    <DataGridTextColumn Header="Notes" Binding="{Binding Path=Notes}" Width="*">
        <DataGridTextColumn.EditingElementStyle>
            <Style TargetType="TextBox">
                <Setter Property="MaxLength" Value="255"/>
            </Style>
        </DataGridTextColumn.EditingElementStyle>
    </DataGridTextColumn>
4

1 回答 1

1

CellEditEnding事件处理程序中,您可以按标题检查列:

private void OnEndEdit(object sender, DataGridCellEditEndingEventArgs e)
{
    if (e.Column.Header.ToString() == "Notes")
    {
        Debug.WriteLine("Saving...");
    }
}
于 2013-07-30T16:25:57.240 回答