In a Modern UI for Wpf (MUI) application, I would like to navigate to a specific instance of an existing page, e.g.:
Page myPageInstance = new Page();
NavigateTo(myPageInstance);
but all available methods, like:
NavigationCommands.GoToPage.Execute("/Pages/Page.xaml", this);
or:
NavigationService nav = NavigationService.GetNavigationService(this);
nav.Navigate(myPageInstance)
or:
NavigationWindow nav = FindAncestor<NavigationWindow>(this);
...
public static T FindAncestor<T>(DependencyObject dependencyObject) where T : DependencyObject
{
var parent = VisualTreeHelper.GetParent(dependencyObject);
if (parent == null) return null;
var parentT = parent as T;
return parentT ?? FindAncestor<T>(parent);
}
do not work (the earlier creates a new page instance, the second doesn't find any NavigationService (nav is null), the latter doesn't find any NavigationWindow (of course, as the root is a FirstFloor.ModernUI.Windows.Controls.ModernWindow))
Any suggestion?
Thanks!