I'm working on a Xamarin Forms App. This App has a ContentPage as MainPage, this ContenPage has 2 buttons. One of them, after being clicked, shows a new Page (I'm using App.Current.MainPage = page;
) and this new page has a Nav Drawer.
The Nav Drawer shows perfectly, and all its pages work fine, but what I want to do is open a new page (lets call it "events") from one of this nav drawer pages. Every time a Nav Drawer Item is clicked, I use the code above:
if (menu == null)
return;
Page displayPage = (Page)Activator.CreateInstance(menu.TargetType); //the error shows here after trying to open my "events" page
Detail = new NavigationPage (displayPage);
menuPage.Menu.SelectedItem = null;
IsPresented = false;
But then, on my Nav Drawer Page, I'm trying to open my "events" page, but I don't know how to open it. I tried to use Navigation.PushAsyng(page) or App.Current.MainPage = page; but none of those work. Everytime I try to open it, this Unhandled Exception shows
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation
I use this reference for creating my nav drawer https://syntaxismyui.com/xamarin-forms-masterdetail-page-navigation-recipe/ So, does someone know how to solve this problem and open my "events" page? I've been trying to do this for a long time without any results.
Thanks!