【问题标题】:Can we customize CommandBar in UWP我们可以在 UWP 中自定义 CommandBar
【发布时间】:2016-11-14 06:03:05
【问题描述】:

我有一个 UWP 应用。在那里,我有一个CommandBar,其中有一些AppBarButton。现在,我需要在同一个命令栏中添加一些自定义的单选按钮,这些单选按钮将组合在一起并准确显示在命令栏的中间(不像默认行为那样右对齐)。

有没有办法使用CommandBar 来实现它?

【问题讨论】:

    标签: wpf uwp commandbar


    【解决方案1】:

    是的,你可以。看看official sample。在示例中,您可以找到很多如何在 UWP 应用程序中使用应用栏的组合

    更新:

    <Page.BottomAppBar>
        <CommandBar>
            <CommandBar.Content>
                <Grid> 
                    <RadioButton />
                 ...  
    

    附言不要忘记HorizontalAlignmentHorizontalContentAlignment 属性

    【讨论】:

    • 嗨,我查看了示例,但找不到将任何其他控件(除了 AppBarButton)添加到 CommandBar 的方法。我的要求是在 CommandBar 中添加一些单选按钮。此外,我需要将这些单选按钮对齐在中心(而不是像 AppBarButton 那样对齐右侧)。
    • 我更新了一个答案。因此,在 UWP 应用中,您可以在 CommandBar 中使用 Content 属性
    • 谢谢,除了对齐部分外它可以工作。我尝试将Grid的Horizo​​ntalAlignment设置为Center,将Button的Horizo​​ntalContentAlignment设置为Center,但它显示在命令栏的最左侧。
    • 就是这样。为 CommandBar 设置 Horizo​​ntalContentAlignment 就可以解决问题。谢谢:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-12
    • 2013-01-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多