GridView does not get focus when the row header of the selected row is clicked from other focus scope

9 posts, 0 answers
  1. Arthur
    Arthur avatar
    22 posts
    Member since:
    Jul 2014

    Posted 30 Jun 2015 Link to this post

    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

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 02 Jul 2015 Link to this post

    Hello Arthur,

    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Arthur
    Arthur avatar
    22 posts
    Member since:
    Jul 2014

    Posted 02 Jul 2015 Link to this post

    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

     

  5. Arthur
    Arthur avatar
    22 posts
    Member since:
    Jul 2014

    Posted 02 Jul 2015 Link to this post

    Please do not missread the steps. I really mean RowHeader not ColumnHeader. Just to save communication cycles. :-)
  6. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 02 Jul 2015 Link to this post

    Hello Arthur,

    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. Christopher
    Christopher avatar
    1 posts
    Member since:
    Oct 2015

    Posted 17 May Link to this post

    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

  8. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 17 May Link to this post

    Hello Christopher,

    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
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  9. Arthur
    Arthur avatar
    2 posts
    Member since:
    Oct 2015

    Posted 17 May Link to this post

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

  10. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 18 May Link to this post

    Hello Arthur,

    So, you have found an even better solution :)

    Regards,
    Maya
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for WPF is Visual Studio 2017 Ready