Hi,
I have the following scenario. I have a RadGridView with a ToolBar above, where the ToolBar contains a TextBox (Filter). The textbox is inside the tool bar's focus scope which is different from the main focus scope of the grid.
If I select a row, go to the filter text box in the tool bar and click on the grid without beginning edit or changing selection (for example on the selected row header) the keyboard focus is not transfered back to the gridview. This is programmed this way in GridViewRow.OnMouseLeftButtonDown.
On the other hand if I look at the TreeListViewRow instead of GridViewRow there is an explicit OnMouseDown-Handler which solves the problem for TreeListViews.
My question ist, why is it implemented this way for GridViewRows? A keyboard focus should always transfer on mouse down, even if the target element is the focused element in its focus scope.
Arthur
8 Answers, 1 is accepted
I must be missing something here as I am not able to reproduce the issue on my side. Will it be possible to take a look at the sample project attached and let me know whether you can reproduce the behavior on it and what the steps for that are ?
Regards,
Maya
Telerik
Hi Maya,
it is simple to reproduce with your sample. To see the problem just use snoop to track the current Keyboard.FocusedElement. Here the steps:
1) Start program
2) Attach snoop or other tool to track keyboard focus
3) Click on row header near "Liverpool" -> Keyboard focus moved to radgridview -> OK
4) Click on text box in toolbar -> Keyboard focus moved to textbox -> OK
5) Click on the same row header near "Liverpool" as before without clicking anywhere else -> Focus stays in textbox -> NOK
Indeed, you are right. Thanks for the clarification. I will update the behavior so that it is similar to the one of RadTreeListView. If the fix passes our QA procedures, it will be available in our internal build on Monday. You can follow the progress of the issue in our feedback portal.
I also updated your Telerik points for the project and the assistance with the steps.
Regards,
Maya
Telerik
Hello,
I have a similar situation but with the column headers. Shouldn't clicking a column header also bring keyboard focus to the RadGridView? Clicking the area of the header that isn't a column, or a group column header if you have one brings it to focus, but clicking an actual column header does not.
If this is how this was designed how would you get around it?
Thanks,
Chris
The easiest way would be to handle Sorting event of RadGridView that will be thrown on clicking the column header and perform the logic you want inside.
Regards,
Maya
Telerik
Hi,
my solution to the problem was that I have written a behavior which is attached by default via our implicit grid style. The behavior does the following and could be adapted to the column header problem also:
private
static
void
OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
GridViewRow control = (GridViewRow)d;
if
(control !=
null
)
{
if
((
bool
)e.NewValue)
{
control.AddHandler(GridViewRow.MouseDownEvent, (MouseButtonEventHandler)OnMouseDown,
true
);
}
else
{
control.RemoveHandler(GridViewRow.MouseDownEvent, (MouseButtonEventHandler)OnMouseDown);
}
}
}
private
static
void
OnMouseDown(
object
sender, MouseButtonEventArgs e)
{
GridViewRow control = (GridViewRow)sender;
if
(!control.IsKeyboardFocusWithin && control.GridViewDataControl !=
null
)
{
control.GridViewDataControl.Focus();
}
}
So, you have found an even better solution :)
Regards,
Maya
Telerik