Justin CI
Justin CI

Reputation: 2741

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

enter image description here

After Tab

enter image description here

Upvotes: 3

Views: 198

Answers (1)

AnjumSKhan
AnjumSKhan

Reputation: 9827

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; });
        });
    }

Upvotes: 1

Related Questions