Share via


CommandBar.DefaultLabelPosition 属性

定义

获取或设置一个值,该值指示标签在命令栏按钮上的位置和可见性。

public:
 property CommandBarDefaultLabelPosition DefaultLabelPosition { CommandBarDefaultLabelPosition get(); void set(CommandBarDefaultLabelPosition value); };
CommandBarDefaultLabelPosition DefaultLabelPosition();

void DefaultLabelPosition(CommandBarDefaultLabelPosition value);
public CommandBarDefaultLabelPosition DefaultLabelPosition { get; set; }
var commandBarDefaultLabelPosition = commandBar.defaultLabelPosition;
commandBar.defaultLabelPosition = commandBarDefaultLabelPosition;
Public Property DefaultLabelPosition As CommandBarDefaultLabelPosition
<CommandBar DefaultLabelPosition="commandBarDefaultLabelPositionMemberName" />

属性值

一个枚举值,该值指示标签在命令栏按钮上的位置和可见性。 默认值为 Bottom

Windows 要求

设备系列
Windows 10 Anniversary Edition (在 10.0.14393.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v3.0 中引入)

注解

默认情况下,应用栏按钮的标签显示在图标下方。 可以将此属性设置为在图标右侧显示标签,或隐藏标签。

可以设置 AppBarButton.LabelPosition 属性以替代此值,并使标签始终折叠为特定应用栏按钮。

版本兼容性

DefaultLabelPosition 属性在 Windows 10 版本 1607 之前不可用。 如果你的应用在 Microsoft Visual Studio 中的“最低平台版本”设置小于本页稍后的“要求”块中显示的“引入版本”,则必须设计和测试应用以考虑到这一点。 有关详细信息,请参阅 版本自适应代码

若要避免应用在以前版本的 Windows 10 上运行时出现异常,请勿在 XAML 中设置此属性,或者在不执行运行时检查的情况下使用它。 此示例演示如何使用 ApiInformation 类在设置此属性之前检查此属性是否存在。

<CommandBar x:Name="commandBar1" Loaded="CommandBar_Loaded">
    ...
</CommandBar>
private void CommandBar_Loaded(object sender, RoutedEventArgs e)
{
    if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.CommandBar", "DefaultLabelPosition"))
    {
        commandBar1.DefaultLabelPosition = CommandBarDefaultLabelPosition.Right;
    }
}

适用于