FreshMvvm icon indicating copy to clipboard operation
FreshMvvm copied to clipboard

Show master page programmatically?

Open codegrue opened this issue 7 years ago • 2 comments

Is there a method to switch to the master view in a master-detail layout via code? I am not displaying the nav bar but want to trigger this. Effectively the equivalent to Xamarin's native:

Ispresented = true

Also, is there a way to replace the root with a new master-detail viewmodel, as in the case where you navigate from a Login screen to a Landing screen with a Menu? For example:

CoreMethods.PushMasterDetailModel<???>();

codegrue avatar Jan 06 '18 01:01 codegrue

I created this workaround, bypassing FreshMVVM, using this article:

https://github.com/twolfprogrammer/Xamarin.Forms-Hamburger-Menu-Example/blob/master/App.xaml.cs

  • save FreshMasterDetailNavigationContainer to a static varible in App.xaml.cs

private static FreshMasterDetailNavigationContainer _masterDetailNav;

  • provide a public property to access the IsPresented value:
        public static bool MenuIsPresented
        {
            get
            {
                return _masterDetailNav.IsPresented;
            }
            set
            {
                _masterDetailNav.IsPresented = value;
            }
        }

The in a viewmodel just do something like this:

        public Command MenuCommand
        {
            get => new Command(() => App.MenuIsPresented = true);
        }

I would prefer an FreshMVVM method if there was one just to be consistent.

codegrue avatar Jan 08 '18 17:01 codegrue

You dont have use default themedmastedetaiilnavigationcontainer class from freshmvvm. you can create a new one and do whatever you want with it. it is totally independent implementation than freshmvvm itself. see how I have done here. https://github.com/rid00z/FreshMvvm/issues/188

EmilAlipiev avatar Feb 09 '18 15:02 EmilAlipiev