Search code examples
datagriduwp-xamlwindows-community-toolkit

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


I know this question has already been asked for WPF DataGrid but the solutions don't apply to DataGrid from Windows Community Toolkit used in UWP.


Solution

  • You could use SelectionChanged and BeginEdit event to do this like following.

    XAML code:

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

    Code behind:

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