I have an application which pulls XAML page paths from a database. I can then use a navigationservice to navigate to the relevant page when need be. However, I have run into a scenario where I would like to instantiate the page with a specific constructor before navigating to that page.
Is it possible to take a string value such as ‘\Pages\MyPage.xaml’ at runtime and create an object MyPage? Obviously, I could do this with a switch statement on the page path, but I would like it to be a whole lot more dynamic than that.
If anyone has any ideas, or has a better way of doing what I’m trying to do, I would greatly appreciate it!
You can parse the string to take off the extension and subdirectory, then take a look at Activator.CreateInstance