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

RadPane Focus child element

1 Answer 320 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 2
Chris asked on 15 Nov 2011, 05:46 PM
Hi,

I'm currently using the RadDocking control in a project.
It's a fairly simple layout with dockable panes on the left of the screen and a document host filling up the rest of the space.

In order to track down this issue I only have 2 panes in the pane group for now.

What I'm trying to do is assign short cut keys to each of the panes.
Specifically, when you press the short cut key for a particular pane that pane will become active and the focus will be on the first control in the pane.

I've defined some RoutedUICommands and used Windows.InputBindings to assign short cut keys to the commands.
The Executed handler for each command does the following:
1. Sets the Selected Item property of the RadPaneGroup to the appropriate pane.
2. Calls control.Focus() on the appropriate control (within that pane).

Unfortunately, this isn't working as it should.

Ridiculously, I've found that by calling DoEvents() in between setting the selected item and setting the focus of the control it works as it should. I know C# doesn't officially have a DoEvents method but if you google it you'll find examples of code that looks like this:

Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { }));


Obviously, this is a hack and I'm keen to fix it the right way.

Any help would be appreciated, I have a sample application which illustrates the point if needed.

Thanks,


CA.


1 Answer, 1 is accepted

Sort by
0
Ivo
Telerik team
answered on 22 Nov 2011, 10:22 AM
Hi Chris,

The easiest way to achieve this is to use the RadDocking ActivePane property instead of SelectedItem of RadPaneGroup. You can find sample application attached that demonstrates how to focus the first element when ActivePane changes.
When opening a RadPane that was into a RadPaneGroup the content of the RadPane is still not loaded so you cannot focus it. Because of this you will have to attach to each of the RadPane's panels Loaded event. Also you will have to attach to the RadDocking ActivePaneChanged event and focus the first child element of the currently selected RadPane.

Hope this helps.

Best wishes,
Ivo
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Docking
Asked by
Chris
Top achievements
Rank 2
Answers by
Ivo
Telerik team
Share this question
or