Reusing menus with mvvm and wpf

I was wondering what is the best way to use the menu in all wpf windows / views.

My application is really not suitable for the navigation model, so it is likely to use the ribbon control.

I tend to create a custom control for the menu and drop it on each view, but also saw a Josh Smith msdn article where it loads user controls.

Are there any other options or established best practices?

Thanks at Advance.

+4
source share
2 answers

I finished the implementation like Josh Smiths; However, I simplified the situation a bit.

All views are usercontrols except MainWindow. MainWindow contains a ContentTemplate that is bound to a property that contains a link to a single UserControl in the view model. Then I have the ApplicationController responsible for managing the life cycle of the view and view of the model. The base ViewModel class used by each view contains a reference to IApplicationController. Then, MainWindowViewModel calls ApplicationController calls to load a new view, etc.

However, 100% of this approach would welcome any further suggestions.

+1
source

Here is what I will probably try:

  • Define the ISharedMenu Interface
  • Create a UserControl that uses ISharedMenu as its DataContext.
  • For each ViewModel you want to use the shared menu, implement the ISharedMenu interface.
0
source

All Articles