microsoft/microsoft-ui-xaml

MenuFlyout's closing behavior should be configurable

Closed this issue · 3 comments

Describe the bug

The <MenuFlyout> 's closing behavior needs to be configurable, so that it doesn't immediately close when the user wants to perform more than one action in the flyout menu.

Steps to reproduce the bug

This is the exact implementation that causes the problematic behavior displayed above to happen

<Button>
    <Button.Content>
        <StackPanel Orientation="Horizontal">
            <FontIcon Glyph="&#xE71C;" />
            <TextBlock Text="Filter" Margin="5,0,0,0" />
        </StackPanel>
    </Button.Content>

    <Button.Flyout>
        <MenuFlyout>

            <ToggleMenuFlyoutItem Text="A" x:Name="A" IsChecked="True">
                <ToggleMenuFlyoutItem.Icon>
                    <FontIcon Glyph="&#xEB41;" />
                </ToggleMenuFlyoutItem.Icon>
            </ToggleMenuFlyoutItem>

            <ToggleMenuFlyoutItem Text="B" x:Name="B" IsChecked="True">
                <ToggleMenuFlyoutItem.Icon>
                    <FontIcon Glyph="&#xECC4;" />
                </ToggleMenuFlyoutItem.Icon>
            </ToggleMenuFlyoutItem>

            <ToggleMenuFlyoutItem Text="C" x:Name="C" IsChecked="False">
                <ToggleMenuFlyoutItem.Icon>
                    <FontIcon Glyph="&#xE770;" />
                </ToggleMenuFlyoutItem.Icon>
            </ToggleMenuFlyoutItem>

            <ToggleMenuFlyoutItem Text="D" x:Name="D"
                IsChecked="False">
                <ToggleMenuFlyoutItem.Icon>
                    <FontIcon Glyph="&#xEC12;" />
                </ToggleMenuFlyoutItem.Icon>
            </ToggleMenuFlyoutItem>

        </MenuFlyout>
    </Button.Flyout>
</Button>

Expected behavior

A property to configure the automatic closing behavior of the MenuFlyout.

Screenshots

20241210-0815-14.8041377.mp4

NuGet package version

WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003

Windows version

Windows 11 (24H2): Build 26100

Additional context

No response

You obviously haven't found the Closing event which allows you to cancel the flyout closing in your event handler.

You obviously haven't found the Closing event which allows you to cancel the flyout closing in your event handler.

@AndrewKeepCoding suggested this method and it's solved my problem.
https://github.com/HotCakeX/Harden-Windows-Security/pull/452/files

@HotCakeX Thanks for chiming in and providing a solution. Closing as there's a valid workaround.