简体   繁体   中英

Selection loses in datagrid when pressing Tab key

I have a datagrid with multiple rows and If I select multiple rows and while editing a row if I press tab key I looses selection on the selected rows,Only current row is selected. I need all other rows to be selected without losing selection.

Please help.

Before Tab

在此输入图像描述

After Tab

在此输入图像描述

Handle Unselected event of the DataGridRow. This is however just an idea, as it wont allow you to Unselect any row. But you can build upon this further, checking for Ctrl key pressed etc.

    void DataGridRow_Unselected(object sender, RoutedEventArgs e)
    {
        DataGridRow row = sender as DataGridRow;

        Task.Factory.StartNew(() =>
        {
            Application.Current.Dispatcher.Invoke(() => { row.IsSelected = true; });
        });
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM