FreshMvvm
FreshMvvm copied to clipboard
Show master page programmatically?
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<???>();
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.
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