CommunityToolkit / WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/communitytoolkit/
Other
5.89k stars 1.38k forks source link

HamburgerMenu doesn't work as expected with CommandBar #1180

Closed SuperJMN closed 7 years ago

SuperJMN commented 7 years ago

Give this XAML, the HamburgerMenu cannot be clicked. What's wrong?

<Page
    x:Class="App9.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App9"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

        <SplitView IsPaneOpen="{Binding ElementName=HamburgerMenu, Path=IsPaneOpen}">
            <SplitView.Pane>
                <Grid Background="Green"></Grid>
            </SplitView.Pane>
            <SplitView.Content>
                <Page >
                    <Grid Background="Blue"></Grid>
                    <Page.TopAppBar>
                        <CommandBar Background="Transparent">
                            <AppBarButton>One</AppBarButton>
                            <AppBarButton>Two</AppBarButton>
                            <AppBarButton>Three</AppBarButton>
                        </CommandBar>
                    </Page.TopAppBar>
                </Page>
            </SplitView.Content>
        </SplitView>

        <controls:HamburgerMenu x:Name="HamburgerMenu" />
    </Grid>
</Page>
avknaidu commented 7 years ago

@SuperJMN Ofcourse this won't work. You are Stacking the CommandBar from inside the splitView on Top of the HamburgerMenu. Height of both controls are 48px. so you will never be able to get to HamburgerMenu.

SuperJMN commented 7 years ago

Thanks for the answer! I didn't know that CommandBar will overlap other elements no matter the order they appear in the XAML. But then, how do I put a HumberguerMenu and CommandBar at the top of a page without overlapping? is this even possible?

ScottIsAFool commented 7 years ago

@SuperJMN do you need to have your splitview content as a page and use the TopAppBar at all? Just place the commandbar in a grid and have it vertically aligned to the top.

nmetulev commented 7 years ago

Closing issue, feel free to re-open if it doesn't solve your issue.