by F-Kroll

Xamarin Tips: Convert string to a Page in Xamarin.Forms

You can open your pages dynamically in your Xamarin.Forms application. For that we can use Type.GetType(string):

async Task OpenPage(object obj)
{
var pageType= Type.GetType($"NamespaceOfYourView.{obj}");
var page = Activator.CreateInstance(pageType) as Page;
await Application.Current.MainPage.Navigation.PushAsync(page );
}

You can read details of Type.GetType in here.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store