question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Navigation fails/ refuses to work if removed and re-added from SpliView.Pane

See original GitHub issue

Describe the bug When a WinUI NavigationView is inside a Splitview.Pane, removing and re-adding it in runtime stops it’s navigation behavior.

Steps to reproduce the bug

Simplest steps to reproduce the behavior:

  1. Create a blank UWP/C# app
  2. Add WinUI nuget package (Microsoft.UI.Xaml)
  3. Edit App.Xaml to add WinUI:
<Application
    x:Class="Test2.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Test2">

    <Application.Resources>
        <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
    </Application.Resources>

</Application>
  1. Add a SplitView in MainPage.xaml. Add WinUI NavigationView inside the pane of the SpliView. Add a button in the Splitview.Content which will add/remove the NavigationView from SpliView.Pane.

MainPage.xaml:

<Page
    x:Class="Test2.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Test2"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:WinUI="using:Microsoft.UI.Xaml.Controls"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <SplitView x:Name="Split" DisplayMode="Inline" IsPaneOpen="True">
            <SplitView.Pane>
                <WinUI:NavigationView x:Name="NavView" IsSettingsVisible="False" IsBackButtonVisible="Collapsed" PaneDisplayMode="Top">
                    <WinUI:NavigationView.MenuItems>
                        <WinUI:NavigationViewItem Content="item 1"/>
                        <WinUI:NavigationViewItem Content="item 2"/>
                    </WinUI:NavigationView.MenuItems>
                </WinUI:NavigationView>
            </SplitView.Pane>

            <Button Content="Add/Remove NavigationView" Click="Button_Click"/>

        </SplitView>
    </Grid>
</Page>

MainPage.xaml.cs:

using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Test2
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (Split.Pane is null)
                Split.Pane = NavView;
            else Split.Pane = null;
        }
    }
}
  1. Build and Run the app. Tap on the navigation items (Item1 and Item2) to ensure that everything works fine.
  2. Remove and Re-add the NavigationView by pressing the Add/Remove NavigationView Button twice.
  3. Now try the navigation items again. It doesn’t work !

Expected behavior Normal navigation behavior.

Version Info

NuGet package version: Microsoft.UI.Xaml 2.0.181018003

Windows 10 version:

  • October 2018 Update (17763)

Device form factor:

  • Desktop

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
YuliKlcommented, Nov 19, 2018

Hi @MuziburRahman , thank you for the explanation and screenshot! If Pivot is accomplishing what you need it to, that’s great and please continue using Pivot. If things still aren’t working to your liking, you can also look into using the Windows Community Toolkit’s TabView control.

1reaction
licanhuacommented, Nov 14, 2018

Muzib,

Thank you for reporting this, and I can reproduce your problem. Will let you if we have update.

You may workaround the problem by collapsing navigationview other than removing/re-adding.

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        //if (Split.Pane is null)
        //    Split.Pane = NavView;
        //else Split.Pane = null;
        if (NavView.Visibility == Visibility.Collapsed)
        {
            NavView.Visibility = Visibility.Visible;
        }
        else
        {
            NavView.Visibility = Visibility.Collapsed;
        }
    }

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: Muzib notifications@github.com Sent: Tuesday, November 13, 2018 9:59:27 PM To: Microsoft/microsoft-ui-xaml Cc: Subscribed Subject: [Microsoft/microsoft-ui-xaml] Navigation fails/ refuses to work if removed and re-added from SpliView.Pane (#18)

Describe the bug When a WinUI NavigationView is inside a Splitview.Pane, removing and re-adding it in runtime stops it’s navigation behavior.

Steps to reproduce the bug

Simplest steps to reproduce the behavior:

  1. Create a blank UWP/C# app
  2. Add WinUI nuget package (Microsoft.UI.Xaml)
  3. Edit App.Xaml to add WinUI:

<Application x:Class="Test2.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Test2">

<Application.Resources>
    <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
</Application.Resources>
</Application>
  1. Add a SplitView in MainPage.xaml. Add WinUI NavigationView inside the pane of the SpliView. Add a button in the Splitview.Content which will add/remove the NavigationView from SpliView.Pane.

MainPage.xaml:

<Page x:Class="Test2.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Test2" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:WinUI="using:Microsoft.UI.Xaml.Controls" mc:Ignorable="d" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
    <SplitView x:Name="Split" DisplayMode="Inline" IsPaneOpen="True">
        <SplitView.Pane>
            <WinUI:NavigationView x:Name="NavView" IsSettingsVisible="False" IsBackButtonVisible="Collapsed" PaneDisplayMode="Top">
                <WinUI:NavigationView.MenuItems>
                    <WinUI:NavigationViewItem Content="item 1"/>
                    <WinUI:NavigationViewItem Content="item 2"/>
                </WinUI:NavigationView.MenuItems>
            </WinUI:NavigationView>
        </SplitView.Pane>

        <Button Content="Add/Remove NavigationView" Click="Button_Click"/>

    </SplitView>
</Grid>
</Page>

MainPage.xaml.cs:

using Windows.UI.Xaml; using Windows.UI.Xaml.Controls;

namespace Test2 { public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        if (Split.Pane is null)
            Split.Pane = NavView;
        else Split.Pane = null;
    }
}

}

  1. Build and Run the app. Tap on the navigation items (Item1 and Item2) to ensure that everything works fine.
  2. Remove and Re-add the NavigationView by pressing the Add/Remove NavigationView Button twice.
  3. Now try the navigation items again. It doesn’t work !

Expected behavior Normal navigation behavior.

Version Info

NuGet package version: Microsoft.UI.Xaml 2.0.181018003

Windows 10 version:

  • October 2018 Update (17763)

Device form factor:

  • Desktop

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Microsoft/microsoft-ui-xaml/issues/18, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AF_9BOKHaUKe2AqDX2T-sA5pDdtzip83ks5uu7E_gaJpZM4YdE5y.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UISplitViewController broken when in tab view controllers
I'm trying to rebasline my app to iOS 14. My app's main entry point for the UI is a tab view controller. Three...
Read more >
The splitview is not opening on debugging
I am using Visual Studio 2015 and learning making UWP Apps. I want to make hamburger style navigation but the splitview doesn't open...
Read more >
Slack confirmed, split view has been deprecated. Windows ...
Split view let you have a thread open and it would persist as a side bar when navigating away from the channel the...
Read more >
Using the UWP SplitView on iOS, Android and WebAssembly ...
In this post we're going to cover one of the basics of app navigation which is the use of the UWP SplitView. If...
Read more >
Navigation and the back stack
The back stack is useful for when the user wants to navigate backwards. Android can remove the current activity from the top of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found