RadPane Focus child element

2 posts, 0 answers
  1. Chris
    Chris avatar
    7 posts
    Member since:
    Oct 2010

    Posted 15 Nov 2011 Link to this post


    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.



  2. Ivo
    Ivo avatar
    390 posts

    Posted 22 Nov 2011 Link to this post

    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,
    the Telerik team

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

Back to Top