First off, I have looked at all the suggested questions and none of them actually answer my question. I see solutions for WinRT or WPF but none that work with UWP.
With that being said, I am looking for a way to do something like this:
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var pageName = ((ListViewItem)((ListView)sender).SelectedItem).Name;
var pageObj = ???? //Some way to ref MyNamespace.MyPage.xaml
MyFrame.Navigate(typeof(pageObj));
}
I have tried to use all combinations of the following:
var pageObj = FindName(pageName);
---
var pageObj = System.Type.GetType(this.GetType().Namespace + "." + pageName);
---
MyFrame.Navigate(typeof(pageObj));
---
MyFrame.Navigate(pageObj);
---
MyFrame.Navigate(typeof(pageName));
---
MyFrame.Navigate(pageName);
And some otherthings I cant quite remember. At best I get a NullReferenceException.
I am fairly new to c# and UWP, so if this is something that is not possible I am sorry for wasting your time. It's just that if I decide to add a new page at some point I don't want to have to edit some switch statement; I just want to add a new ListViewItem and be done with it.
Also, its a learning experience for me. I know how to do switch statements already. Now I would like to do something a little more elegant.
Thank you in advance for any help provided!