Prism Navigation

Docking/MDI for WPF Forum

Posted 8 years ago by Chris Klepeis
Version: 16.1.0630
Avatar

I'm currently evaluation the dock control, and noticed in the example that you use datatemplates to map the viewmodel to the view.

One issue we'd have with that is that datatemplates can be slow with complex views (which we have). Another issue with using viewmodels is that since we have many modules, if we wanted to create a tab document from one module, and that tab document code is from another module, we'd have to introduce a dependency to the other module. With prism navigation we can map a view to a constant string then use that constant anywhere with navigation without having to worry about additional dependencies.

Does / would the dock control work using prism navigation?

E.G.

In the module: Container.RegisterTypeForNavigation<SearchOrderView>(NavigationViewNames.SalesOrder.SearchOrder);

In the view: prism:ViewModelLocator.AutoWireViewModel="True"

Then to load it into the dock we'd use this somewhere else: RegionManager.RequestNavigate(RegionNames.WorkspaceRegion, NavigationViewNames.SalesOrder.SearchOrder);

 

Thanks

Comments (3)

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

Hi Chris,

There are several ways to select a view for a view-model.  We created DockSite to work just like any normal ItemsControl, so all the same sorts of view creation methods you use in an ItemsControl are available to you in DockSite.

1) One option that you saw in the sample was to use view DataTemplates that target certain view-model types, but as you said, you have reasons for not using that.

2) Another way is to create a DataTemplateSelector object to assign to the ToolItemTemplateSelector property.  You could use any logic you want in that selector class to programmatically return a DataTemplate based on the passed-in view-model.

3) Yet another way is to make a class that inherits DockSite and override methods like PrepareContainerForItemOverride and ClearContainerForItemOverride.  Again in this scenario you can provide programmatic logic and you could specify an exact content element if you'd like instead of using a DataTemplate.

We don't have anything built into Docking/MDI that will harness Prism Navigation directly but perhaps you could use the #2 or #3 options above and programmatically access the navigation data to get a view for your view-model?


Actipro Software Support

Posted 8 years ago by Chris Klepeis
Avatar

Thanks. 

I almost have it working by modifying the DockSiteRegionBehavior class from the sample to accomodate prism navigation as well. It'd be great if this was supported by the control as prism navigation is the suggested practice from the maintainer of Prism.

Correct me if I'm wrong, but from the sample, all objects added to the region (visible or not) will remain in memory since they are deactivated in the region, and not removed.

[Modified 8 years ago]

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

I believe that is correct.  A closed docking window will be retained in memory since it is still registered with the DockSite.  Once a docking window unregisters from the DockSite, then it can be freed from memory.  Generally document windows destroy themselves (unregister from the DockSite) on close but tool windows do not.  Tool windows are meant to be reused and reopened.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.