question

shreshtavalluru-3560 avatar image
0 Votes"
shreshtavalluru-3560 asked shreshtavalluru-3560 commented

how can we highlight navigation view item when selected with button in winui3

when navigation view item is selected it should higlight with customised color

windows-app-sdk
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You can use NavigationViewItem to customize the Background or something else color.

1 Vote 1 ·

1 Answer

RoyLi-MSFT avatar image
0 Votes"
RoyLi-MSFT answered shreshtavalluru-3560 commented

Hello,

Welcome to Microsoft Q&A!

You could try to override the corresponding theme resource for the item selected status.

Like this:

         <NavigationView x:Name="NavigationViewControl" >
             <NavigationView.Resources>
                 <SolidColorBrush x:Key="NavigationViewItemBackgroundSelected" Color="Yellow"/>
             </NavigationView.Resources>
             <NavigationView.MenuItems>
                 <NavigationViewItem Content="A" x:Name="A" />
                 <NavigationViewItem Content="B" x:Name="B" />
                 <NavigationViewItem Content="C" x:Name="C" />
             </NavigationView.MenuItems>
         </NavigationView>


Thank you.


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@RoyLi-MSFT after removing cursor from menuitem still the color remains occupied full menu item.only on hover and click of the menu item it should highlight with color

0 Votes 0 ·