I want to Convert a string DashBoard to a type of page named as DashBoard because I wanted to use it in navigation purpose. Normally I navigate to some page like this
this.Frame.Navigate(typeof(DashBoard));
but I want to DashBoard page to be replaced by variable like this
this.Frame.Navigate(typeof(Somestring));
If you know the fully qualified name of
DashBoard
- i.e. which assembly and namespace it's in - you can use reflection to determine what to pass toNavigate
.Look at the docs for System.Reflection.Assembly, in particular
GetTypes
andGetExportedTypes
, depending on what you need.You could use the
Type.GetType(string)
[MSDN]Read the remarks section on how to format the string.
Or you can use reflection:
This can be used as following:
In this example. The function will search in the current assembly for a page with the name TestPage and then navigate to it.