Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle click events of the settings button inside a UWP NavigationView?

Tags:

c#

xaml

uwp

I found that the official NavigationView are introduced in newer versions of Visual Studio and can help easily achieve the Hamburger layout, and by setting the property IsSettingsVisible to True, there will autometically be a settings button at the bottom.

My question is pretty simple: How can I handle the click event of this settings button? I cannot find any corresponding properties.

<NavigationView PaneDisplayMode="LeftCompact" IsSettingsVisible="True">
    <!--I'm expecting some codes like below-->
    <NavigationView.SettingsButton Click="SettingsButton_Click"/>
</NavigationView>
like image 977
Obsidian Avatar asked Nov 17 '25 09:11

Obsidian


1 Answers

Register a new method to the ItemInvoked event and check if it's the Settings button which got invoked by doing so:

C#:

private async void NavigationView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args) {
    if (args.IsSettingsInvoked) {
        // Code here
    }
}

XAML:

<NavigationView IsSettingsVisible="True" ItemInvoked="NavigationView_ItemInvoked">
    <!-- Your XAML -->
</NavigationView>
like image 184
Washington A. Ramos Avatar answered Nov 20 '25 01:11

Washington A. Ramos