by F-Kroll

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

Tuğçe Arar
Apr 2, 2021

--

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.

--

--