上一篇为大家介绍了AppBar 的相关内容,本篇继续介绍CommandBar 的使用方法。与AppBar 相比而言,CommandBar 在开发使用方面较为单一,在按键布局上分为主控区(Primary Commands)与辅控区(Secondary Commands),默认情况下,主控区显示在菜单右侧,辅控区在左侧。

如果应用菜单栏中只包含AppBarButton、AppBarToggleButton、AppBarSeparator 这几个控件,且没有特殊布局格式要求,及可以使用CommandBar 控件。当应用尺寸变化时,CommandBar 也会随之调整尺寸。

<Page.BottomAppBar>
<CommandBar>
<AppBarButton x:Uid="Camera" Icon="Camera" Label="Camera"/>
<AppBarToggleButton x:Uid="Suffle" Icon="Shuffle" Label="Shuffle"/>
<AppBarToggleButton x:Uid="Account" Icon="Account" Label="Account"/>
<AppBarButton x:Uid="Like" Icon="Like" Label="Like"/>
<AppBarButton x:Uid="Dislike" Icon="Dislike" Label="Dislike"/> <AppBarSeparator/> <AppBarButton x:Uid="Add" Icon="Add" Label="Add"/>
<AppBarToggleButton x:Uid="Remove" Icon="Remove" Label="Remove"/>
<AppBarButton x:Uid="Delete" Icon="Delete" Label="Delete"/>
</CommandBar>
</Page.BottomAppBar>

如上面代码,默认所有控件都是分配在主控区及菜单栏右侧,将Add、Remove、Delete 按键放入辅控区是什么样子呢,如下:

<Page.BottomAppBar>
<CommandBar>
<AppBarButton x:Uid="Camera" Icon="Camera" Label="Camera"/>
<AppBarToggleButton x:Uid="Suffle" Icon="Shuffle" Label="Shuffle"/>
<AppBarToggleButton x:Uid="Account" Icon="Account" Label="Account"/>
<AppBarButton x:Uid="Like" Icon="Like" Label="Like"/>
<AppBarButton x:Uid="Dislike" Icon="Dislike" Label="Dislike"/> <AppBarSeparator/> <CommandBar.SecondaryCommands>
<AppBarButton x:Uid="Add" Icon="Add" Label="Add"/>
<AppBarToggleButton x:Uid="Remove" Icon="Remove" Label="Remove"/>
<AppBarButton x:Uid="Delete" Icon="Delete" Label="Delete"/>
</CommandBar.SecondaryCommands>
</CommandBar>
</Page.BottomAppBar>

如上图所示,写入SecondaryCommands 的按键被分配到了菜单栏左侧。关于CommandBar 介绍就到这里,大家可以动手操练一下。

Windows 8.1 新增控件之 CommandBar的更多相关文章

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

    [源码下载] 重新想象 Windows 8.1 Store Apps (72) - 新增控件: AppBar, CommandBar 作者:webabcd 介绍重新想象 Windows 8.1 Sto ...

  2. Windows 8.1 新增控件之 AppBar

    Windows 8.1 与Windows 8 相比已经有了很多改进,从ITPro 角度这篇文章<What's New in Windows 8.1>已经表述的很详细.对开发者来说,最明显的 ...

  3. Windows 8.1 新增控件之 DatePicker

    大年初一来介绍一个简单易用的DatePicker 控件,这个控件是新增的?印象里很早就有了啊,Anyway来看看Windows 8.1 里的DataPicker 有什么功能吧. 先来看看这个代码,很简 ...

  4. Windows 8.1 新增控件之 Hyperlink

    Hyperlink 控件应该不用过多介绍大家肯定十分清楚其作用,它的功能就像HTML中的<a href="">标签一样,只不过是在XAML中实现. 使用Hyperlin ...

  5. Windows 8.1 新增控件之 TimePicker

    之前已经为大家介绍过DatePicker 控件的相关内容,有日期控件当然就得有时间控件,本篇将和各位一起了解TimePicker 的使用方法. 先来介绍一下ClockIdentifier 属性,默认情 ...

  6. Windows 8.1 新增控件之 MenuFlyout

    开始这篇讲解前,我们先来温习一下Flyout 的内容,当触发应用中某个Button 时会有Flyout 出现提示用户该操作接下来将会发生什么.Flyout 简单来说就是一个轻量级信息提示需要用户确认或 ...

  7. Windows 8.1 新增控件之 Flyout

    本篇为大家介绍Flyout 控件,Flyout 属于一种轻量级交互控件,可以支持信息提示或用户交互.与传统Dialog 控件不同的是Flyout 控件可通过直接点击对话框外部区域忽略. Flyout ...

  8. Windows 8.1 应用再出发 - 几种新增控件(1)

    Windows 8.1 新增的一些控件,分别是:AppBar.CommandBar.DatePicker.TimePicker.Flyout.MenuFlyout.SettingsFlyout.Hub ...

  9. Windows 8.1中WinRT的变化(一)——新增控件

    这次WinRT的变化还是不小的,就拿新增控件来说,就有如下几种: AppBar 控件 我以前写过一篇文章接受过如何在WinRT程序中快速创建Metro风格图标,现在MS已经把他们标准化了,就不用我们自 ...

随机推荐

  1. 我的android学习经历

    我为什么选择android? 我基本上前一年的时间都是在学习java的语法和线程之类的,没有注意java的分类,所以到现在慢慢接触到深处的时候我了解到,java的优势主要在web,而我不是特别喜欢网页 ...

  2. cocoapods遇到的问题 (pod: command not found的问题)

    在使用CocoaPod为项目添加第三方类库时,出现了-bash: pod: command not found的问题: 在网上看到了一位哥的方法:确实有效:

  3. AndroidStudio添加依赖库

    以Gson为例 Step1:点击下图中的入口,进入ProjectStructure Step2: 在app项中选择Dependencies窗口,点击右侧的加号 Step3:在搜索框中输入gson,点击 ...

  4. java 中的volatile

    本博客摘录自   http://www.infoq.com/cn/articles/java-memory-model-4/ 当我们声明共享变量为volatile后,对这个变量的读/写将会很特别.理解 ...

  5. 走进云背后:微软Azure web 项目通过web service部署web site

    探索云那不为人知的故事(一):Web Services部署web site 前奏:Windows Azure是微软基于云计算的操作系统,现在更名为“Microsoft Azure”,和Azure Se ...

  6. msysGit管理GitHub代码

    msysGit管理GitHub代码   代码的管理,在日常开发中是很重要的环节,程序员的修炼三部曲——版本控制,单元测试,项目自动化. 本篇就简单的说说通过msysGit来管理GitHub中的代码,实 ...

  7. Servlet/JSP-04 JSP基础

    一. JSP概述 Servlet 是 Java 程序,可以在 Java 程序内部返回一段 HTML 代码(字符串形式)到浏览器,供浏览器解释展示. JSP 是一种脚本语言,在 HTML 内部通过嵌入 ...

  8. MySQL入门(一)

    最近一直都在搞新员工的培训材料,MySQL的培训PPT我居然写了100多页,我都佩服我自己的毅力了.不如现在把这些总结一下,慢慢写到博客里,供入门者参考. 一 关系型数据库 关系型数据库的理论提出于上 ...

  9. Swift实现截屏并保存相册

    func saveToLocal() { //截屏 let screenRect = UIScreen.mainScreen().bounds UIGraphicsBeginImageContext( ...

  10. iOS 解决导航栏左右 BarButtonItem偏移位置的问题

    iOS7 之后,我们直接在导航栏添加barbuttonItem时候,会发现有一定偏移量, 比如: self.navigationItem.leftBarButtonItem = UIBarButton ...