UWP CommandBar更多按钮,除非更改大小,否则不显示

问题描述 投票:0回答:1

我的问题几乎与here相同。

我的CommandBar应该具有以下按钮:

<CommandBar
    DefaultLabelPosition="Right"
    Style="{StaticResource PlaylistCommandBarStyle}">
    <AppBarButton
        Icon="Shuffle"
        Style="{StaticResource PlaylistAppBarButtonStyle}" />
    <AppBarButton
        Icon="Add"
        Style="{StaticResource PlaylistAppBarButtonStyle}" />
    <AppBarButton
        Icon="Rename"
        Style="{StaticResource PlaylistAppBarButtonStyle}" />
    <AppBarButton
        Icon="Pin"
        Style="{StaticResource PlaylistAppBarButtonStyle}" />
    <AppBarButton
        Icon="Clear"
        Style="{StaticResource PlaylistAppBarButtonStyle}"
        Visibility="Collapsed" />
    <AppBarButton
        Icon="Delete"
        Style="{StaticResource PlaylistAppBarButtonStyle}" />
</CommandBar>

当窗口的大小不足以容纳最后一个删除按钮时,它将溢出,然后显示更多按钮。但是,除非我调整窗口大小,否则不会显示more按钮。

答案here非常复杂。我想知道是否有更简单的解决方案。

[PlaylistAppBarButtonStylehere

[PlaylistCommandBarStylehere

uwp win-universal-app
1个回答
1
投票

CommandBar的溢出按钮有两个条件。

首先是屏幕宽度不足以显示完整的按钮列表。

第二个是CommandBar.SecondaryCommands不为空。

您可以尝试将不重要的按钮移到SecondaryCommands列表中。

<CommandBar
    DefaultLabelPosition="Right"
    Style="{StaticResource PlaylistCommandBarStyle}">
    <AppBarButton
        Icon="Shuffle"
        Style="{StaticResource PlaylistAppBarButtonStyle}" />
    <AppBarButton
        Icon="Add"
        Style="{StaticResource PlaylistAppBarButtonStyle}" />
    <AppBarButton
        Icon="Rename"
        Style="{StaticResource PlaylistAppBarButtonStyle}" />
    <AppBarButton
        Icon="Pin"
        Style="{StaticResource PlaylistAppBarButtonStyle}" />
    <CommandBar.SecondaryCommands>
        <AppBarButton
            Icon="Clear"
            Style="{StaticResource PlaylistAppBarButtonStyle}"
            Visibility="Collapsed" />
        <AppBarButton
            Icon="Delete"
            Style="{StaticResource PlaylistAppBarButtonStyle}" />
    </CommandBar.SecondaryCommands>
</CommandBar>

最诚挚的问候。

© www.soinside.com 2019 - 2024. All rights reserved.