Search code examples
wpfmodern-ui

Modern UI - How to make a link load its content in "_top"?


I have a ModernTab control, to which I'm dynamically adding a Link:

InstallationTab.Links.Add(new Link { DisplayName = "Review Configuration", Source = new Uri("/Views/InstallationProgress.xaml", UriKind.Relative) });

I'd like InstallationProgress.xaml to load in the top frame instead of the current content frame.

How can I do this?

enter image description here


Solution

  • I answered my own question, in case anyone else finds themselves here:

    This is just one example of "hijacking" the click on the ModernTab. Here, you can force the content to load in the top frame, for example:

    Handle the SelectedSourceChanged event of the ModernTab:

    MyModernTab.SelectedSourceChanged += MyModernTab_SelectedSourceChanged;

    void MyModernTab_SelectedSourceChanged(object sender, SourceEventArgs e)
    {
        if (e.Source.OriginalString.EndsWith("Foo.xaml"))
        {
            var url = "/Pages/Foo.xaml";
            var bb = new BBCodeBlock();
            bb.LinkNavigator.Navigate(new Uri(url, UriKind.Relative), this, NavigationHelper.FrameTop);
        }
    }