RadDocking in multiple threads

7 posts, 0 answers
  1. Daniel
    Daniel avatar
    5 posts
    Member since:
    Jun 2012

    Posted 18 Jun 2012 Link to this post

    I'm currently working on a project that has different windows opened up in multiple threads. There seems to be a problem with commands running in all but the first thread that is created with a RadDocking element in it.

    Within each thread, a new window is created, with a RadDocing, RadSplitContainer, RadPaneGroup and a single RadPane. The window is then displayed. When you click on the PaneHeader in any window other than the first thread that is opened, the application immediately throws a threading exception: System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.

    This exception occurs even when we have no code other than starting the threads. Has anyone else had this problem? Is there any way to fix this problem?

  2. Daniel
    Daniel avatar
    5 posts
    Member since:
    Jun 2012

    Posted 18 Jun 2012 Link to this post

    I eventually fixed this problem by redefining the style for the PaneHeader. The default styles define the input commands to be executed, by redefining this in the xaml where the docking pane is used it fixed the problem.
  3. Aracna
    Aracna avatar
    22 posts
    Member since:
    Jun 2012

    Posted 18 Jun 2012 Link to this post

    Hi Daniel,

    Could you please share your code, on how you created multiple rad docking panes on multiple threads? I am trying to do the same but I cannot find my way around it.

    It would be great help if you could.

  4. Daniel
    Daniel avatar
    5 posts
    Member since:
    Jun 2012

    Posted 19 Jun 2012 Link to this post

    I created a small test application that creates windows in different threads, each with their own rad docking pane in the window.

    First I set up a window with a button on it that would execute a command to start a new thread

    <Window x:Class="DockingTest.MainWindow"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="MainWindow" Height="60" Width="100">
    <telerik:RadButton Content="Start Thread" Command="{Binding Path=StartThread}"/>

    This is all bound to the MainWindowViewModel which executes the StartThread command.

    public class MainWindowViewModel
    public ICommand StartThread { get; set; }
    public MainWindowViewModel()
    StartThread = new RelayCommand(StartDockingInNewThread);
    private void startNextThread()
    System.Windows.Window w = new System.Windows.Window() { Height = 300, Width = 300 };
    DockingView pv = new DockingView();
    w.Content = pv;
    catch(Exception e)
    var dispatcher = w.Dispatcher;
    if (!dispatcher.HasShutdownStarted)
    private void StartDockingInNewThread()
    Thread thread = new Thread(new ParameterizedThreadStart(
    new Action<object>((o) =>
    thread.Start(new object());

    The method StartDockingInNewThread() creates the new thread, and starts it.
    When startNextThread() executes, it creates the new window, adds the contents of the window, displays it and then invokes Dispatcher.Run() to cause the thread to start listening for events.

    The DockingView is a UserControl that contains a rad docking pane

    <UserControl x:Class="DockingTest.DockingView"
                 xmlns:DockingTest="clr-namespace:DockingTest" mc:Ignorable="d"
            <telerikDocking:RadDocking HasDocumentHost="False" x:Name="_docking">
                        <telerikDocking:RadPaneGroup x:Name="_group"
                        telerikDocking:ProportionalStackPanel.RelativeSize="1, 2"
                            <TextBlock Text="This is some Text"/>

    Under normal, non-threading circuimstances this works as expected. However, when opening up multiple threads with RadDocking, only the first thread opened will work as expected. In order to fix this problem, the style used for the PaneHeader needs to be overwritten.

    I created a Resource Dictionary to overwrite this style

            <!--PaneHeader Style-->
            <Style x:Key="PaneHeaderStyle" TargetType="telerik:PaneHeader">
                <Setter Property="telerik:InputBindingsManager.InputBindings">
                            <MouseBinding Command="telerik:RadDockingCommands.PaneHeaderMenuOpen">
                                    <MouseGesture MouseAction="RightClick" />
            <!--Set the style-->
            <Style TargetType="telerik:PaneHeader" BasedOn="{StaticResource PaneHeaderStyle}" />

    Once you create the Resource Dictionary, then you need to use it in the DockingView by adding it to your UserControl.Resources in the xaml

        <ResourceDictionary Source="Dictionary1.xaml"/>

    After adding this resource dictionary to redefine the input bindings, you can run multple threads without them crashing.

    I hope this helps,

  5. Aracna
    Aracna avatar
    22 posts
    Member since:
    Jun 2012

    Posted 21 Jun 2012 Link to this post

    Thanks Daniel
  6. Vinay
    Vinay avatar
    3 posts
    Member since:
    Mar 2013

    Posted 31 May 2013 Link to this post

    I have a similar problem when I click on the Pane Header, and then it will crash when I launch it in multiple dispatcher thread. I used the solution you described, but it still crashes. Is there any other solutions? I have spent a couple of days trying to fix it.

    Thanks in advance.

  7. George
    George avatar
    1332 posts

    Posted 05 Jun 2013 Link to this post

    Hello Danny,

    You could find a lot of information about how to implement a multi UI thread on net, for example:

    You could run RadDocking in a separate Window using the follow code:

    private void Button_Click_1(object sender, RoutedEventArgs e)
        Thread newWindowThread = new Thread(new ThreadStart(ThreadStartingPoint));
    private void ThreadStartingPoint()
        var tempWindow = new DockingView();

    The RadDocking control is placed into the DockingView which inherits Window. Anyway, please note that the RadDocking is not design to run in different thread and there could be some unexpected problems.


    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top