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.

--

--

--

Software Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Building a JSON parser with TDD (Part 2) — String Theory

How to add a search bar to your React project

Two Factor authentication using NodeJs

ReactJs Animation: Create login/register form with react-spring animation

Better Micro Frontends and Design Systems with Independent Components

Animations with GSAP, JavaScript and React

Imitating react life-cycle methods with useEffect hook

8514086617@ Pankh Clothing customer service 9832782598 Any problems solved please contact support…

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
Tuğçe Arar

Tuğçe Arar

Software Engineer

More from Medium

Flow-Control in C#

Delegating Handlers in C#

Fixing my BF1942 woes with Win32 APIs

Uploading Large Size Files By Using Azure Blob Storage