在 CommandBar 的 SecondaryCommand 上设置图标 [英] Set Icon on SecondaryCommand of CommandBar

查看:31
本文介绍了在 CommandBar 的 SecondaryCommand 上设置图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个命令栏宽度辅助命令:

I have a command bar width secondary commands:

<CommandBar>
    <AppBarButton Icon="Back" Label="Back" Click="AppBarButton_Click"/>
    <AppBarButton Icon="Stop" Label="Stop" Click="AppBarButton_Click"/>
    <AppBarButton Icon="Play" Label="Play" Click="AppBarButton_Click"/>
    <AppBarButton Icon="Forward" Label="Forward" Click="AppBarButton_Click"/>

    <CommandBar.SecondaryCommands>
        <AppBarButton Icon="Like" Label="Like" Click="AppBarButton_Click"/>
        <AppBarButton Icon="Dislike" Label="Dislike" Click="AppBarButton_Click"/>
    </CommandBar.SecondaryCommands>
</CommandBar>

为什么不显示喜欢"和不喜欢"图标?

Why the Like and Dislike icons are not shown?

推荐答案

在 Windows 8.1 中,主要和次要命令是一种将按钮放在左侧和右侧的方法.在 Windows 10 UWP 中,辅助命令被移动到桌面和手机上的弹出菜单.默认情况下,此弹出菜单中不显示图标.

In Windows 8.1 primary and secondary commands were a way to put the buttons on the left and the right. In Windows 10 UWP, secondary commands are moved to a flyout menu on both desktop and phone. Icons are by default not shown in this flyout menu.

SecondaryCommands 集合只能包含 AppBarButton、AppBarToggleButton 或 AppBarSeparator 命令元素.当 CommandBar 打开时,辅助命令显示在溢出菜单中.

The SecondaryCommands collection can contain only AppBarButton, AppBarToggleButton, or AppBarSeparator command elements. The secondary commands are shown in the overflow menu when the CommandBar is open.

来源:MSDN.

如果您想尝试覆盖样式,请查看 generic.xaml 中的 OverflowPopup 控件和 CommandBarOverflowPresenter 样式以帮助您入门.

If you would like to try to override the style, have a look at the OverflowPopup control and CommandBarOverflowPresenter style in generic.xaml to get you started.

C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\10.0.10240.0\Generic\generic.xaml

C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\10.0.10240.0\Generic\generic.xaml

这篇关于在 CommandBar 的 SecondaryCommand 上设置图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆