microsoft / microsoft-ui-xaml

WinUI: a modern UI framework with a rich set of controls and styles to build dynamic and high-performing Windows applications.
MIT License
6.38k stars 683 forks source link

ComboBox don't respond click in a flyout of CommandBar #10181

Closed qhy040404 closed 3 days ago

qhy040404 commented 6 days ago

Describe the bug

I have a ComboBox in a CommandBar. CommandBar will collapse the content that cannot be displayed when the width is insufficient. Now I have a narrow window and the ComboBox is collapsed into the secondary menu. When the ComboBox is in the flyout of the secondary menu, it can be clicked to pop up the candidate items, but the selection cannot be responded normally.

Image

Steps to reproduce the bug

<CommandBar Grid.Column="1" Margin="16,0,0,0" DefaultLabelPosition="Right">
    <CommandBar.Content>
        <!-- Try to fill the CommandBar -->
        <TextBox Width="1000"/>
    </CommandBar.Content>

    <AppBarElementContainer>
        <ComboBox ItemsSource="{Binding SomeList, Mode=OneWay}" SelectedItem="{Binding SomeList.CurrentItem, Mode=TwoWay}"/>
    </AppBarElementContainer>
</CommandBar>

Expected behavior

ComboBox's SelectedItem can be properly set in the flyout

Screenshots

Image

NuGet package version

WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003

Windows version

Windows Insider Build (xxxxx), Windows 11 (22H2): Build 22621

Additional context

Insider 26120 Windows 11 24H2 (26100)

Skittles2519 commented 6 days ago

@qhy040404 I could reproduce your issue from your provided code. To fix this, you will need to update your AppBarElementContainer to allow focus on interaction. This will allow you to interact with your ComboBox when it's displayed in the flyout. <AppBarElementContainer AllowFocusOnInteraction="True">

qhy040404 commented 5 days ago

Thanks a lot. It works.