Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
mdmozibur opened this issue Nov 14, 2018 · 11 comments · Fixed by #249
Closed
2 tasks done

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

mdmozibur opened this issue Nov 14, 2018 · 11 comments · Fixed by #249
Labels
area-NavigationView NavView control bug Something isn't working team-Controls Issue for the Controls team

Comments

@mdmozibur
Copy link
Contributor

mdmozibur commented Nov 14, 2018

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
@licanhua
Copy link
Contributor

licanhua commented Nov 14, 2018 via email

@YuliKl
Copy link

YuliKl commented Nov 14, 2018

@Muziburrahman, can you explain your scenario? Putting NavigationView into a SplitView isn't expected usage of this control. Can you help me understand what behavior you're trying to achieve by adding/removing NavigationView?

@mdmozibur
Copy link
Contributor Author

@YuliKl I don't know how you decide which uses are appropriate and which are not, but look at the portion inside red rectangle, which is using Pivot control now (as NavigationView had it's problem), but my 1st try was NavigationView here, the animated focus follower of NaviagtionView looked kinda cool. Also, the header area of the Pivot control takes so much space. But I am out of option now.

image

@jevansaks
Copy link
Member

That seems like a reasonable usage, but not one we've encountered before. Is @licanhua's workaround suggestion an option for you, @Muziburrahman ?

@jevansaks jevansaks added the bug Something isn't working label Nov 15, 2018
@mdmozibur
Copy link
Contributor Author

It might be a workaround, but I have not tried it yet, I am using Pivot now.

@mdmozibur
Copy link
Contributor Author

Hi @jevansaks , I have tested @licanhua 's workaround. No, it doesn't work.
Even if I don't remove the NavigationView, just close the pane and open it, the NavigationView doesn't work.

@YuliKl
Copy link

YuliKl commented 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.

@licanhua
Copy link
Contributor

@Muziburrahman , could you please share a small project with the workaround if you still stick with navview? I verified the 'Collapse NavView then make it visible' workaround before and it should work.

@mdmozibur
Copy link
Contributor Author

@licanhua sorry, I couldn't reproduce it in a new project. Your workaround works fine in the new project, but however, it doesn't in my original project. I'll try though.

@msft-github-bot
Copy link
Collaborator

🎉This issue was addressed in #249, which has now been successfully released as Microsoft.UI.Xaml v2.1.190131001-prerelease.:tada:

Handy links:

@msft-github-bot
Copy link
Collaborator

🎉This issue was addressed in #249, which has now been successfully released as Microsoft.UI.Xaml v2.1.190219001-prerelease.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NavigationView NavView control bug Something isn't working team-Controls Issue for the Controls team
Projects
None yet
5 participants