我有一个DataGrid,我将10 DataGridTextColumn绑定到它。我添加了一个CellEditEnding来捕获编辑文本的时间,以便我可以保存它。我想知道是否有可能只获得CellEditEnding
<DataGridTextColumn Header="Notes" Binding="{Binding Path=Notes}".
这是DataGrid
<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>
答案 0 :(得分:1)
在CellEditEnding
事件处理程序中,您可以按标题列检查:
private void OnEndEdit(object sender, DataGridCellEditEndingEventArgs e)
{
if (e.Column.Header.ToString() == "Notes")
{
Debug.WriteLine("Saving...");
}
}