This is what I have:
<Window.Resources>
<DataTemplate DataType="{x:Type viewModel:LogsViewModel}"> <ig:XamDockManager LayoutMode="FillContainer" Background="LightBlue" > <ig:XamDockManager.Panes> <ig:SplitPane ig:XamDockManager.InitialLocation="DockedRight"> <ig:ContentPane x:Name="StateTransDock" Header="State Transissions" IsPinned="True" AllowClose="False" CloseButtonVisibility="Hidden"> </ig:ContentPane> </ig:SplitPane> </ig:XamDockManager.Panes> </ig:XamDockManager> </DataTemplate>
<DataTemplate DataType="{x:Type viewModel:ReportsViewModel}">
<Label FontSize="50">THIS IS WHERE THE REPORTS GO</Label>
</DataTemplate> </Window.Resources>
<ContentControl Content="{Binding CurrentPageViewModel}" Grid.Row="1" Grid.Column="1"/>
So I switch the content out based on what is clicked in the application by assigning the appropriate view model to CurrentPageViewModel. The initial view model that gets loaded is the one with the dock manager (viewModel:LogsViewModel). When I switch to viewModel:ReportsViewModel then back to viewModel:LogsViewModel in the application I get this exception:
The 'InitialLocation' cannot be changed once a SplitPane is associated with a 'XamDockManager'
How can I get around this using a solution that keeps my UI decoupled from the view model? Thanks
Hello Kris,
I may have done something slightly different than you because while I'm getting the same exception, I'm getting it immediately when trying to switch to the ReportsViewModel. I'm investigating the exception to see if there is a solution. I will update you once I know more.
I think this forum post by Andrew Smith explains what is going on in your scenario and it also provides a way to resolve it. I tested it out in my sample and it seemed to take care of the exception. I can now switch between the two view models without an issue. http://ko.infragistics.com/community/forums/p/51711/271763.aspx#271763
I'm glad it worked! Let me know if you have any further questions on this matter.
Yes, this worked. I'm also a bit new to WPF so the example app definitely helped. Thanks.