TabControl with MVVM

Docking/MDI for WPF Forum

Posted 12 years ago by Nils Bräutigam
Version: 12.1.0560
Avatar

Hi,

 

we are using ActiPro-TabbedMdiHost inside a DockSite following MVVM-Pattern regarding the Example given by ActiPro. The Bindings (DocumentItemsSource, ToolItemsSource) work fine. We attach a Style for both and inside the Styles we set the property "ContentTemplateSelector" and establishing new Document-/ToolWindows works great with the assigned DataTemplates.

 

Now two issues / questions arised:

1. If we use ItemContainerRetentionMode="Wrapped" the DataContext of the View is not set to the ViewModel but to the wrapping ContentControl.

2. What happens after Closing a DocumentWindow? We understood the documentation so far, that the window-object still exists but is not open. Is there any connection between ViewModel-DataTemplate-View-Window still existing?

 

 

Best regards.

Comments (3)

Answer - Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Nils,

1) I did some testing with our MVVM demo and found that the docking windows we create have their DataContext set to the ViewModel.  I then modified a View in that sample to show the type name of the DataContext and it was the ViewModel.  So I'm not sure how you are seeing #1.

2) We do not automatically destroy any documents created via MVVM, since we don't necessary have access to modify the bound ViewModel collection.  You are responsible for removing the associated ViewModel from whatever collection you bind to when the window is closed.  Once you do so, then all traces of the object will be removed on our end.


Actipro Software Support

Posted 12 years ago by Nils Bräutigam
Avatar

Thank you for the response.

2) Ok, I asked because we have some issues with GarbageCollector. Indeed, I remove my ViewModels from the corresponding collection, but I was wondering whether the Windows are closed or destroyed.

1) If I use ItemContainerRetentionMode="Wrapped" the DataContext of my View is a ContentControl with its Content set to my ViewModel. I tried the same thing with your example - and you're right - there, the ContentControl is not there. For my ViewModel I use an ObservableCollection instead of a DeferrableObservableCollection - could this be the reason for the difference?

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Nils,

1) Odd, but it shouldn't matter what sort of enumerable you bind to since we just gather the items from it.  First maybe try to figure out what differences you have between our sample and your project.  If that doesn't help resolve the issue, try to repro it in a new simple sample project that has minimal code to make it happen.  Then email to that our support address and reference this post.  Please rename any .zip file extension so it doesn't get spam blocked.

2) If you remove a ViewModel, its related window should be destroyed.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.