Appbar Button 标签自动定位 UWP [英] Appbar Button label positions automatically UWP

查看:23
本文介绍了Appbar Button 标签自动定位 UWP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 UWP 应用.我正在使用 Appbar 按钮来显示操作的快速图标按钮.问题是,标签会自动与图标水平放置,而有些标签仍放置在图标下方.有什么办法可以固定标签位置吗?下图是为了更清楚地了解问题:

I am working on a UWP app. I am using Appbar buttons to show quick Icon buttons for actions. The issue is, The labels automatically get placed horizontally to the icon while some are still placed below the icon. Is there any way they the label position can be fixed? Below is the picture for clearer understanding of the issue:

但理想情况下我希望它们看起来像下面

But ideally I want them to look like below

有什么方法可以确保它们(图标及其各自的标签)保持垂直对齐.下面是我的代码:

Is there any way of making sure they(the icons and their respective labels) remain vertically aligned. Below is my code:

<AppBarButton Label="Share" Grid.Column="2" HorizontalAlignment="Center">
    <AppBarButton.Icon>
        <PathIcon HorizontalAlignment="Center" Data="ShareIconPathDataHere"/>
    </AppBarButton.Icon>
</AppBarButton>
<AppBarButton Label="Add to" Grid.Column="3" HorizontalAlignment="Center">
    <AppBarButton.Icon>
        <PathIcon HorizontalAlignment="Center" Data="AddToIconPathDataHere"/>
    </AppBarButton.Icon>
</AppBarButton>
<AppBarButton Label="Report" Grid.Column="4" HorizontalAlignment="Center">
    <AppBarButton.Icon>
        <PathIcon HorizontalAlignment="Center" Data="ReportIconPathDataHere"/>
    </AppBarButton.Icon>
</AppBarButton>

推荐答案

AppBarButton 用于 CommandBar 内部时,设置标签的位置就像设置一样简单CommandBarBottomDefaultLabelPosition.

When AppBarButton is used inside a CommandBar, setting the position of the label is as easy as setting the DefaultLabelPosition of the CommandBar to Bottom.

除此之外,您还可以尝试一些方法.

Outside of it, there are a couple of things you could try.

  1. 尝试在每个 AppBarButton 上设置 IsCompact="False".
  2. 如果 1. 不起作用,请获取 AppBarButton 的默认样式 这里,去掉视觉状态LabelOnRight下的Storyboard.因此,即使控件要求标签右对齐,也没有设置它的状态,因此视觉上不会发生任何变化.
  1. Try setting IsCompact="False" on each AppBarButton.
  2. If 1. doesn't work, go grab the default style for the AppBarButton here, and remove the Storyboard under the visual state LabelOnRight. So even when control asks the label to align right, there's no state to set it hence nothing visually will be changed.

希望这会有所帮助.

这篇关于Appbar Button 标签自动定位 UWP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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