Search code examples
c#wpfmvvmviewmvvmcross

MVVM Cross WPF Region Implementation


How do I realize with MVVM Cross and WPF this view presentation; a menu, tabs and content views? I can't find any actual example how to do that. Here is an outdated implementation https://github.com/ThallisonRhanniel/MvvmCross-Samples/tree/master/XPlatformMenus but I want to use MvvmCross(6.x) and MvvmCross.Platforms.Wpf(6.x).

MainWindow:

[MvxWindowPresentation(Identifier = nameof(MainWindow), Modal = false)]
public partial class MainWindow : MvxWindow<MainWindowViewModel>

Menu:

[MvxContentPresentation(WindowIdentifier = nameof(MainWindow), StackNavigation = true)]
[MvxRegion("MenuContent")]
[MvxViewFor(typeof(MenuViewModel))]
public partial class MenuView

tab bars:

[MvxContentPresentation(WindowIdentifier = nameof(MainWindow), StackNavigation = true)]
[MvxRegion("PageContent")]
[MvxViewFor(typeof(TabViewModel))]
public partial class TabView

to use a region Attribute;

public class MvxRegionPresentationAttribute : MvxBasePresentationAttribute
{
    public string RegionName { get; set; }
    public string WindowIdentifier { get; set; }
}

Inside the MainWindow.xaml;

<Frame x:Name="MenuContent"
       Grid.Column="0"
       NavigationUIVisibility="Hidden"></Frame>

<Frame x:Name="PageContent"
       Grid.Column="1"
       NavigationUIVisibility="Hidden"></Frame>

How do I implement Regions in MVVMCross 6.x?


Solution

  • After searching all mvvmcross wpf github projects I found various implementations but only one updatet version; https://github.com/eiadxp/MvvmCross.Platforms.Wpf.ItemsViewPresenter it uses MvvmCross(6.x) and MvvmCross.Platforms.Wpf(6.x).