0

I have a button and a datagrid. They are located on the same window. I need to give focus to selected row after the button is clicked. Seems to be not as straightforward as I've thought.

So I've got a DataGridRow object. I call DataGridRow.Focus(), but the focus is still there. After reading this incredible topic I've tried using FocusManager to loose focus on the button, also tried settings Button.IsFocusable = false and then setting to true back again. Also tried giving focus to my row using this:

var scope = FocusManager.GetFocusScope(MyDataGrid);
FocusManager.SetFocusedElement(scope, row);

But it didn't help. Probably I do not understand how FocusManager works well enough. Could someone give me a clue how to give focus to a row?

Community
  • 1
  • 1
Bogdan Verbenets
  • 25,686
  • 13
  • 66
  • 119
  • what happens if you `DataGrid.Focus()`, then `DataGridRow.Focus()`; OR `DataGrid.Focus()`, then `DataGrid.SelectedIndex = -1`, `DataGrid.SelectedIndex = indexOfRow`.. – Jake Berger Mar 08 '12 at 14:57

1 Answers1

0
row.Focusable = true;
row.Focus();
Bogdan Verbenets
  • 25,686
  • 13
  • 66
  • 119