Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Introduction

I want to make the header button to be used to minimize items with a one click action, not double one

Screenshot of the header button

Source Code

    StackPanel stackPanel = new StackPanel();

    InitializeComponent();


    NavigationView navigationView = new NavigationView();
    navigationView.PaneDisplayMode = NavigationViewPaneDisplayMode.LeftMinimal;
    
    navigationView.IsPaneOpen = false;

    NavigationViewItem navigationViewItem = new NavigationViewItem();

      void NavigationView(object sender, TappedRoutedEventArgs e)
    {
        navigationView.IsPaneOpen = true;

    }
    navigationViewItem.Icon = new SymbolIcon(Symbol.Admin);
    navigationViewItem.Content = "Test";
    


    navigationView.MenuItems.Add(navigationViewItem);

    stackPanel.Children.Add(navigationView);


    Content = stackPanel;

Problem

I want to run the code when the header button clicked once, not twice, but I don't know how to change the source code to do that.

question from:https://stackoverflow.com/questions/65945926/enable-one-click-instead-of-double-click-when-clicking-navigationviewpanedisplay

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
117 views
Welcome To Ask or Share your Answers For Others

1 Answer

By testing, when clicking the header button, items are minimized. The default operation is once click. It works well.

In addition, why did you create UI through code behind? I suggest you could create it through xaml code. For example:

<StackPanel>
        <NavigationView PaneDisplayMode="LeftMinimal" IsPaneOpen="True">
            <NavigationView.MenuItems >
                <NavigationViewItem Content="Test" Icon="Admin" />
            </NavigationView.MenuItems>
        </NavigationView>
 </StackPanel>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...