Windows Phone8.1中的CommandBar

开篇之前:

若对Windows 8.1的相关Appbar和CommandBar控件感兴趣,强烈推荐王磊老师的博客园

链接:重新想象 Windows 8.1 Store Apps (72) - 新增控件: AppBar, CommandBar

以及不知道名字的博主对WP8.1中Appbar阐述的一篇文章:http://www.dotblogs.com.tw/eternaltung/archive/2014/05/07/wpappbar.aspx


好了,下面就Windows Phone8.1,以及看了以上两位的文章之后,列举下我的感悟:

WP8.1中只有BottomAppBar,没有TopAppBar。因为就人体体验和美感来说,将Appbar设计到手机到上方并不人性化。

CommandBar控件有几个很有用也很让人糊涂的属性

1.ClosedDisplayMode

设为Minimal则将Appbar隐藏到最小;设为Compact则将Appbar正常显示,如下图所示:

                     


2.PrimaryCommands和SecondaryCommands属性

Windows 8.1中两个属性就是字面上的意思,一前一后,从左往右排列

Windows Phone 8.1中前者还是按照从左往右排序的,而后者并不是继续排列下去,而是变成MenuItem列表的形式,如下图区别:

<span style="font-size:18px;"><Page.BottomAppBar>
        <CommandBar x:Name="commonBar" IsSticky="True" ClosedDisplayMode="Compact">
            <AppBarToggleButton Icon="Like" Label="Like"/>
            <AppBarToggleButton Icon="Dislike" Label="Dislike"/>
            <AppBarButton Icon="Library" Label="Library"/>
            <AppBarButton Icon="Stop" Label="Stop"/>
            <!--以上部分没写在CommandBar.PrimaryCommands中,但默认自动添加进其中-->
            <CommandBar.SecondaryCommands>
                <AppBarButton Icon="Like" Label="Like"/>
                <AppBarButton Icon="Dislike" Label="Dislike"/>
                <AppBarButton Icon="Library" Label="Library"/>
                <AppBarButton Icon="Stop" Label="Stop"/>
            </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.BottomAppBar></span>

3.IsSticky和IsOpen属性

这部分请参考微软MSDN上给出的解释,很详细很好

链接:AppBar Class

IsOpen属性:获取或设置指示AppBar是否可见的值

IsSticky属性:获取或设置指示 AppBar是否在光消散时不关闭的值

false - 显示 AppBar 后,如果用户触摸了非 AppBar 区域则 AppBar 会自动隐藏,默认值

true - 显示 AppBar 后,即使用户触摸了非 AppBar 区域,AppBar 也不会自动隐藏,需要通过底部边缘手势或者右键

或者win+z或者api使其隐

默认情况下,应用程序栏会在用户在应用程序栏之外的任何位置与您的应用程序交互时关闭。这称为光消散。要使命

令可见,可以通过将 IsSticky 属性设置为 true 来更改关闭

模式。当应用程序条是便笺,并且仅在用户右击、按下 Windows+Z 或从屏幕的顶边或下边重击时关闭

OnClosed方法:在 AppBar从可见更改为隐藏时调用

OnOpened方法:Invoked when the AppBar changes from hidden to visible, or is first displayed

Closed事件:在 AppBar 从可见更改为隐藏时发生

Opened事件:在 AppBar 从隐藏更改为可见时发生

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值