This is a migrated thread and some comments may be shown as answers.

RadGridView keyboard navigation column header

8 Answers 142 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bryan
Top achievements
Rank 1
Bryan asked on 01 Mar 2017, 11:59 PM

Hello,

I am writing a desktop application using WPF and RadGridView. I need to be able to operate 100% of the application without a mouse (keyboard navigation to every aspect of the application).

 

Is it possible to access column headers via keyboard navigation? If so, how do you do it?

 

Thanks.

8 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 06 Mar 2017, 03:03 PM
Hi Bryan,

I am afraid that the control does not support utilizing all of its functionalities with the keyboard only. May I kindly ask you to share some details on the exact behavior you are aiming at?

In addition, you can take a look at the Keyboard Support topic.

Regards,
Stefan X1
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Bryan
Top achievements
Rank 1
answered on 07 Mar 2017, 03:10 PM
I want to be able to navigate into column headers via keyboard navigation. I want to go from RadGridView to the column headers using the tab keys like how it navigates the cells. Once it's done with the headers it should transition into to the cells. If it reaches the top of the cells it should transition into the header.
0
Stefan
Telerik team
answered on 10 Mar 2017, 12:24 PM
Hello Bryan,

Thanks for the clarification.

We have already replied you in the support thread you opened regarding this requirement. In order to avoid double posting, I would kindly ask you to continue any further communication regarding this topic in the support thread.

Thanks in advance for understanding.

Best Regards,
Stefan X1
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
AdaDog
Top achievements
Rank 1
answered on 21 Jun 2018, 03:24 PM
Could you provide information about solution provided in the support ticket?
0
Stefan
Telerik team
answered on 26 Jun 2018, 11:01 AM
Hello Doug,

I am pasting the reply of my colleague from the support thread for your reference as well attaching the sample application.

I prepared a basic project that illustrates how to modify RadGridView's tab navigation, which I am attaching to my post. The general idea behind it is cancelling the default navigation logic in certain occasions. To accomplish this, I am using a custom commands provider, clearing the default commands when a certain condition is met. Another important modification is the addition of a focusable border in the GridViewHeaderCell's template. It is named "FocusableSort", if you want to find it in the theme file. 
The border is needed as the default template elements are not focusable. When the border gets focused, you will be able to execute sorting by processing its KeyDown event. A similar approach can be used for opening the filtering dropdown.


Hope this helps.

Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
AdaDog
Top achievements
Rank 1
answered on 08 May 2019, 06:56 PM

I've been working with the code provided in this post and noticed that the CustomProvider does not actually do anything. Access to the headers is solely achieved by via a Border with Focusable="True" on line 1568, but keyboard navigation gets trapped in the header with a Tab press. In the CustomProvider, the return pendingCommands line in the if (headerRow.Cells... block never gets called. Also, focusedCell is always null because the focusedElement, which must be a grid does not have a ParentOfType<GridViewHeaderCell>.

 

Some other questions:

The clubsGrid is not a focus scope yet a cell can retain logical focus as if the grid did act as a focus scope. Can you please explain the focus scopes related to the RadGridView?

 

The sample is very buggy. Could you provide another?

0
AdaDog
Top achievements
Rank 1
answered on 09 May 2019, 02:27 PM

Something that is particularly interesting: if you use the following code, then you would expect no keyboard events to get fired, but with the sample code provided above, the header tabbing continues to work.

public override IEnumerable<ICommand> ProvideCommandsForKey(Key key)
{
        var pendingCommands = base.ProvideCommandsForKey(key).ToList();
        pendingCommands.Clear();
        return pendingCommands;
}

 

I verified that the visual tree has one and only one focus scope, the main window, by walking up the tree from each focused element.

When tabbing from the header to the data cells presenter, the CurrentCell property is advanced. This seems to be caused by the RadGridViewCommands.MoveNext command. The code in the zip file clears the commands when the last header cell has keyboard focus. How do you cancel the MoveNext command so the that CurrentCell property is not advanced? Clearing the pendingCommands does not work.

0
Vladimir Stoyanov
Telerik team
answered on 13 May 2019, 12:39 PM
Hello Doug,

Thank you for the provided code snippet. 

Firstly, please allow me to say that the project attached to my colleague's reply is not a fully implemented solution. It serves as a guideline on how the desired requirement can be implemented. That said, note that by default the RadGridView column headers cannot be navigated with the keyboard and a lot of customization is needed in order to achieve this functionality. 

With the above information in mind, I will address your questions: 

You are correct that the main customization is the addition of a Border inside the GridViewHeaderCell ControlTemplate. This Border has its Focusable property set to True. This allows for tabbing back and forward inside the header cells and is handled by native WPF logic. This is why tabbing through the headers works even after the "pendingCommands" are cleared.

As for the focus scopes, the RadGridView actually does not define any focus scopes inside it. In the context of the sample application, the focus scope variable is not necessary. It would be needed, if additional custom focus scopes are defined.

I am attaching an updated version of the sample project to serve as guidance on how the custom functionality can be implemented. The main idea is to handle the scenario when the border inside the last GridViewHeaderCell is focused and also when the first GridViewCell of the first row is focused. Feel free to tweak the approach in order to suit your exact scenario. Also, note that I have not tested the approach extensively and you should do so before including it in your application. 

I hope you find this helpful.

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Bryan
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Bryan
Top achievements
Rank 1
AdaDog
Top achievements
Rank 1
Vladimir Stoyanov
Telerik team
Share this question
or