Skip to content

Dynamically adding AppBarButton to CommandBarFlyout's secondary command clips the background #6864

Closed as not planned
@roxk

Description

@roxk

Describe the bug

Dynamically adding items to secondary command of a CommandBarFlyout has rendering artifact.

Steps to reproduce the bug

  1. Create a new UWP blank app
  2. Add the follow context flyout to MainPage.xaml
<!-- Generated stack panel in the template -->
<StackPanel ...>
  <!--  Add this -->
  <StackPanel.ContextFlyout>
    <muxc:CommandBarFlyout x:Name="commandBarFlyout" Opened="commandBarFlyout_Opened">
        <muxc:CommandBarFlyout.SecondaryCommands>
            <AppBarButton Label="Short name"/>
            <AppBarButton Label="Medium length name"/>
            <!-- Uncomment to see static long name doesn't reproduce the issue -->
            <!-- <AppBarButton Label="Static loooooooooooooooooooooooong name"/> -->
        </muxc:CommandBarFlyout.SecondaryCommands>
    </muxc:CommandBarFlyout>
  </StackPanel.ContextFlyout>
  <!- Generated button in the template -->
  <Button .../>
</StackPanel>
  1. Add the following to MainPage.cpp
void MainPage::commandBarFlyout_Opening(IInspectable const&, IInspectable const&)
{
    const auto defaultCount = 2;
    if (commandBarFlyout().SecondaryCommands().Size() > defaultCount)
    {
        commandBarFlyout().SecondaryCommands().RemoveAtEnd();
    }
    AppendCommand();
}

Windows::Foundation::IAsyncAction MainPage::AppendCommand()
{
    co_await 1s;
    co_await resume_foreground(Dispatcher());
    AppBarButton button;
    button.Label(L"Dynamic loooooooooooooooooooooooong name");
    commandBarFlyout().SecondaryCommands().Append(button);
}
  1. Launch the app, right click the button to show command bar flyout
  2. Observe the command bar flyout has normal background
  3. After the dynamic app bar button is added, observe the menu background is clipped at the original width, revealing the content underneath in the extra width, whereas the border is extending to new width just fine

Expected behavior

The background isn't clipped at (6).

Screenshots

image

NuGet package version

Microsoft.UI.Xaml 2.7.0

Windows app type

  • UWP
  • Win32

Device form factor

Desktop

Windows version

Windows 11 (21H2): Build 22000

Additional context

Repro: https://github.com/roxk/CommandBarFlyoutClipping

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions