[UWP]我无法自动隐藏/显示看到CommandBar的更多按钮 [英] [UWP]I can't auto hide/show see more button of CommandBar

查看:92
本文介绍了[UWP]我无法自动隐藏/显示看到CommandBar的更多按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个UWP应用程序。


我的设备操作系统版本号为15063.413,我的应用目标版本是Windows 10周年纪念版(10.0; Build 14393)。


我想自动显示/隐藏"查看更多"按钮,当CommandBar没有辅助命令时,我希望它自动隐藏,否则它应该显示。


我看到
appbar's  doc
。它说我可以使用OverflowButtonVisibility 属性允许应用程序更改此默认自动隐藏行为,
但似乎无效。

< Grid Background =" {ThemeResource ApplicationPageBackgroundThemeBrush }"> 
< CommandBar x:Name =" bottomCommandBar" OverflowButtonVisibility = QUOT;自动">
< AppBarButton x:Name =" searchButton"标签= [搜寻"图标= QUOT;查找与QUOT; />
<! - < CommandBar.SecondaryCommands>
< AppBarButton Label ="帮助"图标= [说明" />
< /CommandBar.SecondaryCommands> - >
< / CommandBar>
< / Grid>

我们可以看到它始终显示"查看更多"按钮。



<请告诉我如何使其发挥作用。


最好的问候,


Jerry





.Net Windows C#

解决方案

< p style ="margin-bottom:0.0001pt; line-height:normal"> 你好Jerry FH吴



当你设置属性
OverflowButtonVisibility auto 时,更多按钮仍然可见。因为
AppBarButton 具有标签属性。 CommandBar 将标签位置设置为默认值,并按
已关闭状态隐藏标签。更多按钮的效果不仅显示
SecondaryCommands ,还显示 PrimaryCommands (标签信息)的详细信息。因此,当
OverflowButtonVisibility为auto 时,无论命令栏是否具有辅助命令,都会显示更多按钮。如果要在命令栏没有辅助命令时隐藏更多按钮,或者当命令栏具有属性
OverflowButtonVisibility auto 的辅助命令时显示它,则可以设置 DefaultLabelPosition属性正确或折叠如:

< CommandBar x:Name =" bottomCommandBar" OverflowButtonVisibility = QUOT;自动" DefaultLabelPosition = QUOT;折叠"> 
< AppBarButton x:Name =" searchButton"标签= [搜寻"图标= QUOT;查找与QUOT; />
< CommandBar.SecondaryCommands>
< AppBarButton Label ="帮助"图标= [说明" />
< /CommandBar.SecondaryCommands>
< / CommandBar>




属性的默认状态是bottom。



祝你好运,


Roy





I'm writing an UWP app.

My device OS build version is 15063.413, my app target version is Windows 10 Anniversary Edition(10.0;Build 14393).

I want to auto show/hide the "See More" button, When CommandBar have no secondary commands I want it auto hide otherwise it should be show.

I see the appbar's doc. It said that I can use the OverflowButtonVisibilityproperty allows apps to change this default auto-hide behavior, but it seems not work.

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <CommandBar x:Name="bottomCommandBar" OverflowButtonVisibility="Auto">
            <AppBarButton x:Name="searchButton" Label="Search" Icon="Find"/>
            <!--<CommandBar.SecondaryCommands>
                <AppBarButton Label="Help" Icon="Help"/>
            </CommandBar.SecondaryCommands>-->
        </CommandBar>
</Grid>

We can see it always show the "See More" button.

Please tell me how to make it work.

Best Regards,

Jerry


.Net Windows C#

解决方案

Hi Jerry F H Wu

When you set the property OverflowButtonVisibility auto, and the more button is still visible. Because the AppBarButton has a Label property. CommandBar set the label position at bottom default and hide the label by the Closed state. The effect of the more button is not only showing the SecondaryCommands but also showing the details of PrimaryCommands(the label infomation). So the more button will always show no matter whether the command bar has a secondary command, when the OverflowButtonVisibility is auto. If you want to hide the more button when command bar has no secondary commands or show it when command bar has secondary commands by the property OverflowButtonVisibility auto, you can set the DefaultLabelPosition property right or collapsed like:

<CommandBar x:Name="bottomCommandBar" OverflowButtonVisibility="Auto" DefaultLabelPosition="Collapsed">
    <AppBarButton x:Name="searchButton" Label="Search" Icon="Find"/>
    <CommandBar.SecondaryCommands>
        <AppBarButton Label="Help" Icon="Help"/>
    </CommandBar.SecondaryCommands>
</CommandBar>

The default state of the property is bottom.

Best regards,

Roy



这篇关于[UWP]我无法自动隐藏/显示看到CommandBar的更多按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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