RadPanes lose their DataTemplate when it moves from being docked to floating

3 posts, 1 answers
  1. Eric
    Eric avatar
    13 posts
    Member since:
    Jun 2015

    Posted 10 Jul 2015 Link to this post

    The DataTemple of my RadPane are lost when the RadPane goes from being docked to floating. I am using the RadDocking control with MVVM thus I am using the DockingPaneFactory class. So far I have the following XAML in my MainWindow.xaml file.

    <Window … >
            <DataTemplate DataType=“{x:Type ViewModelA}”>
                <TextBlock Text=”ViewModelA” />
            <DataTemplate DataType=“{x:Type ViewModelB}”>
                <TextBlock Text=”ViewModelB” />

    The XAML above defines two DataTemplates for my two View Models called ViewModelA and ViewModelB. Next I have my RadDocking XAML that defines three RadSplitContainers and the DockingPanesFactory.

    <telerik:RadDocking PanesSource=”{Binding Panes}”>
        <telerik:RadSplitContainer InitialPosition=”DockedLeft”>
            <telerik:RadPaneGroup x:Name=”LeftPaneGroup” />
        <telerik:RadSplitContainer InitialPosition=”DockedRight”>
            <telerik:RadPaneGroup x:Name=”RightPaneGroup” />
        <telerik:RadSplitContainer InitialPosition=”DockedBottom”>
            <telerik:RadPaneGroup x:Name=”BottomPaneGroup” />
            <local:MyDockingPanesFactory />

    Now I have my DockingPanesFactoryClass.

    public class MyDockingPanesFactory : DockingPanesFactory {
        protected override void AddPane(…) {
           . . . .
        protected override RadPane CreatePaneForItem(object item) {
            if (item is DockPaneViewModel) {
                return new RadPane() {
                    Header = ((DockPaneViewModel)item).Header,
                    Tag = ((DockPaneViewModel)item).InitialLocation,
                    DataContext = item,
                    Content = item
            } else {
                throw new ArgumentException(“Invalid Type”);

    The above code sets the Header, Tag, DataContext, and Context of the new RadPane based on property of the ViewModel which inherits from a specific DockPaneViewModel. The key here is that the Content of the RadPane is set to the ViewModel so that the DataTemplate defined in the MainWindow.xaml can be discovered using its DataType.

    Lastly, in my MainWindowViewModel (which is the DataContext for the MainWindow.xaml), I define the Panes collection for the binding of the PaneSource property in the RadDocking control.

    public class MainWindowViewModel : ViewModelBase {
        public ObservableCollection<DockPaneViewModel> Panes { get; set; }
        public MainWindowViewModel() {
            Panes = new ObservableCollection<DockPaneViewModel>() {
                new ViewModelA(),
                new ViewModelB()

    When this application is run everything looks as expected and the RadPanes are docked in the correct location. In one of the RadPanes I see the text “ViewModelA” and in the other I see “ViewModelB” so I know the DataTemples are being applied. Now when I pull one of the RadPanes off and make it floating its DataContext seems to be lost and it simply shows the class name in the RadPane. Docking the RadPane back into the RadDocking control does not restore its DataTemplate.

    Why do the DataTemples of my RadPanes seem to get removed when I move the RadPane from being docked to being floating?

  2. Answer
    Nasko avatar
    556 posts

    Posted 14 Jul 2015 Link to this post

    Hi Eric,

    When a Pane goes floating it is placed in another window that is not in the same visual tree as the Docking control. So, if the DataTemplates are placed in the MainWindow.Resources (that seems to be case in your scenario based on the provided code - snippets and description) they wont' be applied for the floating Panes (they are in another Windows). Please, define the DataTemplates in the App.xaml file, so they could be applied for all the Panes as expected when they become floating and are placed in another window.

    Please, give a try to the proposed above approach and let us know if it worked for you.

    Hopes this helps.

    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. DevCraft banner
  4. Eric
    Eric avatar
    13 posts
    Member since:
    Jun 2015

    Posted 14 Jul 2015 Link to this post

    Yup that worked perfectly. I was going to eventually move the DataTemplate(s) to the App.xaml but when I was testing I just kept them in the Windows.Resources. Thanks for the reply.
Back to Top