My NavigationView Items background color doesn't revert to its unselected color when I change selections. I have been trying all kinds of styles and settings and can't seem to get this working correctly.
See original GitHub issueCurrent XAML:
<Control.Resources>
<vmc:NullableIntToIntConverter x:Key="NullableIntToIntConverter"/>
<SolidColorBrush x:Key="NavigationViewTopPaneBackground" Color="White"/>
<SolidColorBrush x:Key="TopNavigationViewItemForegroundPointerOver" Color="#78a2c7"/>
<SolidColorBrush x:Key="TopNavigationViewItemForegroundPressed" Color="Black"/>
<SolidColorBrush x:Key="TopNavigationViewItemBackgroundPointerOver" Color="#a3c0d9"/>
<SolidColorBrush x:Key="TopNavigationViewItemBackgroundPressed" Color="#78a2c7"/>
<SolidColorBrush x:Key="TopNavigationViewItemBackgroundSelected" Color="White"/>
<SolidColorBrush x:Key="NavigationViewItemForeground" Color="White"/>
<SolidColorBrush x:Key="NavigationViewItemBackground" Color="#477DAC"/>
<SolidColorBrush x:Key="NavigationViewItemBorderBrush" Color="#6696c0"/>
<SolidColorBrush x:Key="NavigationViewSelectionIndicatorForeground" Color="#477DAC"/>
<DataTemplate x:Key="MasterNavItemTemplate">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding HeaderTitle, Mode=OneWay}"
Style="{StaticResource NavigationViewItemHeaderTextStyle}"
FontWeight="Normal"
FontSize="20"/>
</Grid>
</DataTemplate>
<DataTemplate x:Key="DetailContentTemplate">
<ScrollViewer VerticalScrollMode="Auto" BorderBrush="#477DAC" BorderThickness="1" >
<ContentPresenter Content="{Binding Content}" Padding="0,0,8,0" />
</ScrollViewer>
</DataTemplate>
</Control.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<muxc:NavigationView
x:Name="nvSubMenu"
IsBackButtonVisible="Collapsed"
IsSettingsVisible="False"
IsEnabled="True"
HorizontalAlignment="Left"
PaneDisplayMode="Top"
IsPaneToggleButtonVisible="False"
AlwaysShowHeader="False"
MenuItemsSource="{Binding SubLevelMenuList}"
MenuItemTemplate="{StaticResource MasterNavItemTemplate}">
</muxc:NavigationView>
<ContentPresenter
x:Name="DetailContentPresenter"
Grid.Row="1"
HorizontalAlignment="Left" VerticalAlignment="Top"
Content="{x:Bind nvSubMenu.SelectedItem, Mode=OneWay, TargetNullValue=1}"
ContentTemplate="{StaticResource DetailContentTemplate}">
</ContentPresenter>
</Grid>
Visual Studio 2019 Enterprise Version 16.6.5 Target version: Windows 10, version 1903 (10.0; Build 18362) Min version: Windows 10, version 1809 (10.0; Build 17763)
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Change the color of a checked menu item in a navigation ...
Final step would be to change your NavigationView ... Step 4: To change icon color: set the selector to all the items with...
Read more >Navigation component no longer shows option for ...
I went to update a style on my navigation component but the option ... shows option for background color for selected menu item...
Read more >Change background colour of mobile nav menu
Change background colour of mobile nav menu · 1) Select Header · 2) Set the view to mobile on the bottom settings part...
Read more >Bottom navigation - Material Design
Bottom navigation bars allow movement between primary destinations in an app.
Read more >Swiftui list disable selection. items, id: \. Also there's an AD
The SwiftUI List view has many styles to choose from. ... But the problem is that it doesn't change the text color to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think it is an issue with your code. It does look like the bug that was fixed. The default colors have the same background for normal and pressed, so I’m guessing it repros there as well but just not visible. If you can update and ship on the pre-release that would be a better option. But If you absolutely cannot update, then this is a super hacky workaround to update the presenter visual state by hand.
It appears to be working fine. My original concern was that it was in a prerelease versus an official release. Closing it is fine. If something changes I will let you know. Thanks.