Hi,
I am trying to make xamDockManager work in the following scenario:
- MVVM mode - mainwindow's viewmodel (MainWindowVM) is DependencyObject exposing ObservableCollection of child ViewModelBases, also a DependencyObject (PageBaseVM)
- each page view model (Page1VM, Page2VM), etc is inherited from PageBaseVM and has its own DataTemplate with matching user control inside
- I need to have those pages appear as Tabbed MDI with ability to resize/rearrange, etc without floating out
I came across two different Infragistics.Windows.Extensions projects here on this forum but neither had any help - I am getting a whole bunch of NullReferenceExceptions or, after some changes, InvalidCast exception (Page1VM <> ContentPane).
I have tried to replace colleciton of page VMs to collection of ContentPanes, which I succeeded with, but instead of expected result i got several square panes docked one below another with wrong DataContext (DataTemplate was not applied).
Due to corporate policy, i am unable to provide any sample but to reproduce NREs it is enough to change
Window_DockBindingViewModel : Infragistics.PropertyChangeNotifier
to
Window_DockBindingViewModel : DependencyObject
and adjust code from normal properties to DependencyProperty-based.
Any ideas which direction can i expore next to get job done?
Cheers,
Alex
Hello Alex,
Thank you for the provided information.
I have been looking into it. You cannot bind the DataTemplates directly to the XamDockManager. What I can suggest is to use them as Content for the ContentPanes as it is shown in the samples application from the blog post.
Please do not hesitate to let me know if you have any further questions on this matter.
Hi Gergana,
Thanks for pointing to the sample - those two I found were different. I will look into this one.
As for clarification - yes, you're right. Page1VM and Page2VM should be Content and, probably, DataContext of ContentPane, and ContentTemplate must be looked up in the resources, i.e. there is DataTemplate for each Page1VM and Page2VM defined.
Something like this:
<Window>
<Window.DataContext>
A DependencyObject with ObservableCollection<PageBaseVM> Pages {get;} prepooulated with Page1VM and Page2VM
</Window.DataContext>
<Window.Resource>
<DataTemplate DataType="Page1VM">
<Page1Control/>
</DataTemplate>
<DataTemplate DataType=Page2VM>
<Page2Control/>
<XamDockingManager ItemsSource="{Binding Pages}"....
......
</XamDockingManage>
</Window>
Thank you for posting!
I have been looking into your post and it seems that I am missing something from your scenario. Would you please provide me with more detailed information regarding where are you adding Page1VM and Page2VM? Are you adding them as content of a ContentPanes?
Also if you want to data bind the ContentPanes I can suggest this blog, where this is functionality is explained: http://es.infragistics.com/community/blogs/blagunas/archive/2013/09/24/xamdockmanager-data-binding-contentpanes-with-mvvm.aspx.
Regarding the DataTemplate, that you have mentioned - do you want to change the appearance of the ContentPane?
Looking forward to hearing from you.