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

NavigationView - CanDrag causes all MenuItem's to remain highlighted once pressed #3131

Closed
Parth opened this issue Aug 14, 2020 · 4 comments
Closed
Labels
area-NavigationView NavView control team-Controls Issue for the Controls team

Comments

@Parth
Copy link

Parth commented Aug 14, 2020

Describe the bug

I'm using a Hierarchical Navigation View as described here.

Works as expected, but when I add the CanDrag property to my DataTemplate, I experience what I believe is a rendering bug:

Xaml under normal circumstances:

<Page x:Class="lockbook.FileExplorer"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:lockbook"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
      mc:Ignorable="d">
    <Page.Resources>
        <DataTemplate x:Key="NavigationViewMenuItem"
                      x:DataType="local:File">
            <muxc:NavigationViewItem Content="{x:Bind Name}"
                                     Tag="{x:Bind Id}"
                                     IsExpanded="{x:Bind Expanded}"
                                     MenuItemsSource="{x:Bind Children}" />
        </DataTemplate>
    </Page.Resources>

    <Grid>
        <muxc:NavigationView x:Name="navview"
                             MenuItemsSource="{x:Bind Categories, Mode=OneWay}"
                             MenuItemTemplate="{StaticResource NavigationViewMenuItem}"
                             ItemInvoked="{x:Bind OnItemInvoked}"
                             Expanding="OnItemExpanding"
                             IsBackButtonVisible="Collapsed"
                             Collapsed="OnItemCollapsed"
                             PaneDisplayMode="Left">
            <StackPanel Margin="10,10,0,0">
                <TextBlock Margin="0,10,0,0"
                           x:Name="ExpandingItemLabel"
                           Text="Last Expanding: N/A" />
                <TextBlock x:Name="CollapsedItemLabel"
                           Text="Last Collapsed: N/A" />
            </StackPanel>
        </muxc:NavigationView>
    </Grid>
</Page>

Which produces:

image

The Bug:

Xaml when experiencing the bug:

<Page x:Class="lockbook.FileExplorer"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:lockbook"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
      mc:Ignorable="d">
    <Page.Resources>
        <DataTemplate x:Key="NavigationViewMenuItem"
                      x:DataType="local:File">
            <muxc:NavigationViewItem Content="{x:Bind Name}"
                                     Tag="{x:Bind Id}"
                                     IsExpanded="{x:Bind Expanded}"
                                     CanDrag="True" <---------
                                     MenuItemsSource="{x:Bind Children}" />
        </DataTemplate>
    </Page.Resources>

    <Grid>
        <muxc:NavigationView x:Name="navview"
                             MenuItemsSource="{x:Bind Categories, Mode=OneWay}"
                             MenuItemTemplate="{StaticResource NavigationViewMenuItem}"
                             ItemInvoked="{x:Bind OnItemInvoked}"
                             Expanding="OnItemExpanding"
                             IsBackButtonVisible="Collapsed"
                             Collapsed="OnItemCollapsed"
                             PaneDisplayMode="Left">
            <StackPanel Margin="10,10,0,0">
                <TextBlock Margin="0,10,0,0"
                           x:Name="ExpandingItemLabel"
                           Text="Last Expanding: N/A" />
                <TextBlock x:Name="CollapsedItemLabel"
                           Text="Last Collapsed: N/A" />
            </StackPanel>
        </muxc:NavigationView>
    </Grid>
</Page>

Which produces the following when you click on MenuItems:
image

Strangely (and perhaps something that's useful) if I get rid of CanDrag and allow a hot reload, it doesn't go away until I click on each item. But then it behaves normally once again.

Version Info

NuGet package version:

[Microsoft.UI.Xaml 2.4.0] (and 2.4.3)

Windows app type:

UWP Win32
Yes
Windows 10 version Saw the problem?
Insider Build (xxxxx)
May 2020 Update (19041) Yes
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Additional context

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Aug 14, 2020
@Parth
Copy link
Author

Parth commented Aug 16, 2020

This seems to happen even when dragging is completely disabled. If you try to click on a NavigationItem and move away without unclicking the item remains highlighted.

@Parth
Copy link
Author

Parth commented Aug 16, 2020

Able to completely suppress the issue by adding these:

        <SolidColorBrush x:Key="NavigationViewItemBackgroundPointerOver"
                         Color="Transparent" />
        <SolidColorBrush x:Key="NavigationViewItemBackgroundPressed"
                         Color="Transparent" />
        <SolidColorBrush x:Key="NavigationViewItemBackgroundSelectedPressed"
                         Color="Transparent" />

As a very short term workaround.

@StephenLPeters
Copy link
Contributor

@Parth we made a few fixes in this space, can you try again with the latest 2.5 prerlease and report back if it still reproduces?

@StephenLPeters StephenLPeters added area-NavigationView NavView control team-Controls Issue for the Controls team needs-author-feedback Asked author to supply more information. and removed needs-triage Issue needs to be triaged by the area owners labels Aug 17, 2020
@Parth
Copy link
Author

Parth commented Aug 19, 2020

This seems to be fixed in 2.5 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NavigationView NavView control team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

4 participants