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

Problems with a DockingPanesFactory when setting the DataContext in XAML

2 Answers 205 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 29 Jun 2015, 10:23 PM

We have an existing WPF application that uses a similar UI library to Telerik. We are considering moving to Telerik for many reasons but one is the MVVM support for the RadDocking control. I have been reading and creating some test code and I came across something odd.

I am setting the DataContext of my View/Window using the following XAML.

 

<Window ...>
 
    <Window.Resources>
        <vm:MainWindowViewModel x:Key="MainWindowViewModel />
    </Window.Resources>
 
    <Grid DataContext={StaticResource MainWindowViewModel}">
 
    </Grid>
 
</Window>

Inside the Grid I have a RadDocking that uses the DockingPanesFactory. When I set the DataContext in XMAL (shown above), and I put a break point in the AddPane override for the DockingPanesFactory, the radDocking.SplitItems has zero items the first time.  

If I set the DataContext in the code-behind of the View/Window using the following…

public MainWindow(){
    InitializeComponent();
    this.DataContext = new MainWindowViewModel();
}

 â€¦and now look at the AddPane override for the DockingPanesFactory then the radDociing.SplitItems does NOT contain zero items.

 So if I set the DataContext in XAML the Designer in Visual Studio shows the correct layout but at runtime it puts each RadPane in its own container but if I set the DataContext in code behind the Designer does not work at all but it looks as expected at runtime.

 Why does the DataContext of my View/Window have to be set in code-behind to get the DockingPanesFactory to work correctly at runtime?

 Thanks,

   -eric

2 Answers, 1 is accepted

Sort by
0
Accepted
Kalin
Telerik team
answered on 02 Jul 2015, 08:19 AM
Hello Eric,

In order to get it working correctly would need to define the custom DockingPanesFactory at the very end of the Docking definition:

<telerik:RadDocking PanesSource="{Binding Panes}">
    <telerik:RadSplitContainer InitialPosition="DockedLeft">
        <telerik:RadPaneGroup  x:Name="LeftPaneGroup">
        </telerik:RadPaneGroup>
    </telerik:RadSplitContainer>
    <telerik:RadSplitContainer InitialPosition="DockedBottom">
        <telerik:RadPaneGroup x:Name="BottomPaneGroup">
        </telerik:RadPaneGroup>
    </telerik:RadSplitContainer>
    <telerik:RadDocking.DockingPanesFactory>
        <local:CustomDockingPanesFactory />
    </telerik:RadDocking.DockingPanesFactory>
</telerik:RadDocking>

This way everything will load at the correct moment.

Hope this helps.

Regards,
Kalin
Telerik
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
0
Eric
Top achievements
Rank 1
answered on 02 Jul 2015, 07:57 PM
Thank you very much for the reply. I can verify that your suggestion does correct the issue I am seeing. This might be a good addition to the help for the DockingPanesFactory class. Thanks.
Tags
Docking
Asked by
Eric
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Eric
Top achievements
Rank 1
Share this question
or