有没有一种方法可以在 UWP 的 DataGrid XAML 控件中单击一次或在它们获得焦点时编辑单元格?

Is there a way to edit cells in the DataGrid XAML control for UWP with only one click or when they get focus?

我知道这个问题已经针对 WPF DataGrid 提出,但解决方案不适用于来自 Windows UWP 中使用的社区工具包的 DataGrid。

您可以使用 SelectionChanged and BeginEdit 事件来执行此操作,如下所示。

XAML代码:

<controls:DataGrid x:Name="dataGrid1"
…
SelectionChanged="dataGrid1_SelectionChanged">

后面的代码:

private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            dataGrid1.BeginEdit();         
        }