Skip to content

Instantly share code, notes, and snippets.

@rid00z
Created June 18, 2014 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rid00z/a0f4599e54c10e07afc1 to your computer and use it in GitHub Desktop.
Save rid00z/a0f4599e54c10e07afc1 to your computer and use it in GitHub Desktop.
A RootNavigation page for a Mvvm in Xamarin.Forms
public class RootContainerPage : MasterDetailPage, IRootNavigation
{
ContentPage _menuPage;
NavigationPage _contactNavPage, _quotesNavPage;
public RootContainerPage ()
{
_contactNavPage = new NavigationPage (BasePageModel.ResolvePageModel<ContactsRootPageModel> (null));
_quotesNavPage = new NavigationPage (BasePageModel.ResolvePageModel<QuotesRootPageModel> (null));
Detail = _contactNavPage;
_menuPage = new ContentPage ();
_menuPage.Title = "Menu";
var listView = new ListView();
listView.ItemsSource = new string[] { "Contacts", "Quotes" };
listView.ItemSelected += (sender, args) =>
{
if ((string)args.SelectedItem == "Contacts")
Detail = _contactNavPage;
if ((string)args.SelectedItem == "Quotes")
Detail = _quotesNavPage;
IsPresented = false;
};
_menuPage.Content = listView;
Master = new NavigationPage(_menuPage) { Title = "Menu" };
}
public void PushPage (Page page, BasePageModel model)
{
((NavigationPage)Detail).PushAsync (page);
}
public void PopPage ()
{
((NavigationPage)Detail).PopAsync ();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment