Search code examples
c#wpfmodern-ui

WPF: Understanding ModernUI LinkNavigator


I am a newb. First time with C# and WPF w/ ModernUI Framework.

I'm trying to understand how I would properly initialize another ModernWindow as well as destroy the object when the back arrow is clicked. The window loads fine but going back doesn't destroy the object. Do I have to handle a close event somewhere to properly dispose of it?

public void navigateMediaSelection(object sender, RoutedEventArgs e)
{
    ModernWindow window = new ModernWindow();

    try
    {
        window.LinkNavigator.Navigate(new Uri("/Pages/MediaView/MovieView.xaml", UriKind.Relative), this);
    }
    catch (Exception error)
    {
        ModernDialog.ShowMessage(error.Message, FirstFloor.ModernUI.Resources.NavigationFailed, MessageBoxButton.OK);
    }
}

Solution

  • It appears ModernWindow is not the right object for navigation. Rather, use BBCodeBlock.

    Updated code:

    public void navigateMediaSelection(object sender, RoutedEventArgs e)
    {
        BBCodeBlock window = new BBCodeBlock();
    
        try
        {
            window.LinkNavigator.Navigate(new Uri("/Pages/MediaView/MovieView.xaml", UriKind.Relative), this);
    
        }
        catch (Exception error)
        {
            ModernDialog.ShowMessage(error.Message, FirstFloor.ModernUI.Resources.NavigationFailed, MessageBoxButton.OK);
        }
    
    }