admin管理员组

文章数量:1301491

I'm trying to move the hamburger menu button from NavigationView into the title bar, similar to how the back button is placed. This behavior can be seen in the Community Toolkit Gallery

I know that custom title bar support was ported to the Windows App SDK in version 1.6, but it doesn't seem to work the same way as before. I haven't found any documentation on how to achieve this.

How can I place the pane button inside the title bar using the Windows App SDK?

I'm trying to move the hamburger menu button from NavigationView into the title bar, similar to how the back button is placed. This behavior can be seen in the Community Toolkit Gallery

I know that custom title bar support was ported to the Windows App SDK in version 1.6, but it doesn't seem to work the same way as before. I haven't found any documentation on how to achieve this.

How can I place the pane button inside the title bar using the Windows App SDK?

Share edited Feb 11 at 4:35 Kauã Ferreira Leal dos Santos asked Feb 11 at 4:35 Kauã Ferreira Leal dos SantosKauã Ferreira Leal dos Santos 113 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You need to create a custom title bar.

Set the ExtendsContentIntoTitleBar property to true. And then call SetTitleBar to switch to a new title bar element.

    public MainWindow()
    {
        this.InitializeComponent();
        ExtendsContentIntoTitleBar = true;
        SetTitleBar(TitleBar);

    }

You could add the button to the title bar in the xaml.

<Grid>

    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition/>
    </Grid.RowDefinitions>

    <Grid x:Name="TitleBar" >
        <Button x:Name="HamburgerButton" Content="☰" Click="HamburgerButton_Click" />
    </Grid>

    <NavigationView x:Name="NavigationViewControl" Grid.Row="1" IsBackButtonVisible="Collapsed" IsPaneToggleButtonVisible="False">
        
    </NavigationView>

</Grid>

.cs file:

    private void HamburgerButton_Click(object sender, RoutedEventArgs e)
    {
        
        NavigationViewControl.IsPaneOpen = !NavigationViewControl.IsPaneOpen;
    }

本文标签: winui 3hamburger menu button inside TitlebarStack Overflow