microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

Cannot change NavigationViewItem foreground color in Top mode

Open AndrewKeepCoding opened this issue 3 years ago • 1 comments

Describe the bug

NavigationViewItem Foreground is not respected in Top mode.

This closed issue #2105 might be related.

Steps to reproduce the bug

<NavigationView PaneDisplayMode="Top">
    <NavigationView.MenuItems>
        <NavigationViewItem Content="Default Menu Item" />
        <NavigationViewItem Content="Red Menu Item" Foreground="Red" />
        <NavigationViewItem Content="Green Menu Item" Foreground="Green" />
        <NavigationViewItem Content="Blue Menu Item" Foreground="Blue" />
    </NavigationView.MenuItems>
</NavigationView>

Expected behavior

NavigationViewItem foreground should change in Top mode as it does in Left mode.

Screenshots

Left mode works. image

Top mode doesn't work. image

NuGet package version

WinUI 3 - Windows App SDK 1.1.3

Windows app type

  • [ ] UWP
  • [X] Win32

Device form factor

Desktop

Windows version

Windows 11 (22H2): Build 22621, Windows 11 (21H2): Build 22000

Additional context

I also checked these properties but they work without a problem.

  • Background
  • FontSize
  • FontWeight

AndrewKeepCoding avatar Jul 27 '22 06:07 AndrewKeepCoding

NavigationViewItem Top style is likely not template binding correctly to the foreground property

ranjeshj avatar Sep 16 '22 21:09 ranjeshj

Removing this line fixes the issue. I'm not sure why there's a separate foreground for Top style.

<Setter Target="NavigationViewItemPresenter.Foreground" Value="{ThemeResource TopNavigationViewItemForeground}" />

AndrewKeepCoding avatar Sep 30 '22 07:09 AndrewKeepCoding

Closing this because it works on WindowsAppSDK v1.3.230602002.

AndrewKeepCoding avatar Jul 16 '23 06:07 AndrewKeepCoding