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