简体   繁体   中英

How to Use Navigation Push Asycn in Master Detail Page

I want to make my xamarin forms app when the menu item is clicked instead change the master detail page it go to another page and shows navigation bar with back button in the top. but i got confused in how to change the on menu item selected, here is my onmenuitemSelected

private void OnMenuItemSelected(object sender, SelectedItemChangedEventArgs e)
{

        var item = (DrawerItem)e.SelectedItem;
        Type page = item.TargetType;

        //Navigation.PushAsync((Page)Activator.CreateInstance(page));
        //new NavigationPage((Page)Activator.CreateInstance(page));

        Detail = new NavigationPage((Page)Activator.CreateInstance(page));
       IsPresented = false;
    }

As you can see in the comment tag i already try to do Navigation.Push async and tried New NavigationPage only without Detail but when im click the menu item its do nothing, so what code should i write to do that. and so here what i try to do 正确的导航 and this is what i get when i click the item in the masterdetail page 在此处输入图片说明

what code should i write to able do that ?

nevermind i already found the solution to my problem, here if you have same problem like me

private void OnMenuItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var item = (MasterPageItem)e.SelectedItem;
Type page = item.TargetType;
// Detail = new NavigationPage((Page)Activator.CreateInstance(page));
Detail.Navigation.PushAsync((Page)Activator.CreateInstance(page));
IsPresented = false;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM