Windows 8.1 新增控件之 AppBar
Windows 8.1 与Windows 8 相比已经有了很多改进,从ITPro 角度这篇文章《What's New in Windows 8.1》已经表述的很详细。对开发者来说,最明显的变化就是开始菜单的磁贴尺寸,有大、中、小号之分。搜索功能也集成了Bing,使其更加强大。

同时,Windows 8.1 也新增了一些控件(如下),本篇将为大家介绍AppBar 控件的一些使用方法。
• AppBar
• CommandBar
• DatePicker
• Flyout
• Hub
• Hyperlink
• MenuFlyout
• SettingsFlyout
• TimePicker
AppBar 顾名思义就是为Windows 8.1 应用提供更加方便快捷的应用菜单栏,通常AppBar 是隐藏的,在App 中右键鼠标就可以使其显示。在AppBar 中可以加入AppBarButton、AppBarToggleButton、AppBarSeparator。应用中常规按钮都是矩形,AppBar中的按钮均为圆形,并且通过Label 与Icon 属性设置按钮的名称和图案。

在应用中添加AppBar 其实也很简单,以下面代码为例。AppBar 中加入了Grid 布局,同时在StackPanel 中各放入了一些AppBarButton。运行应用程序后,便可看到这些Button 之间不同的区别,相比而言AppBarToggleButton 提供了多种变换状态,且包含一些特殊事件和属性(可参考AppBarToggleButton)。
<Page.BottomAppBar>
<AppBar>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*"/>
<ColumnDefinition Width="50*"/>
</Grid.ColumnDefinitions>
<StackPanel x:Name="LeftPanel" Orientation="Horizontal" Grid.Column="0" HorizontalAlignment="Left">
<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"/>
</StackPanel>
<StackPanel x:Name="RightPanel" Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right">
<AppBarButton x:Uid="Add" Icon="Add" Label="Add" />
<AppBarToggleButton x:Uid="Remove" Icon="Remove" Label="Remove"/>
<AppBarSeparator/>
<AppBarButton x:Uid="Delete" Icon="Delete" Label="Delete"/>
</StackPanel>
</Grid>
</AppBar>
</Page.BottomAppBar>

所有按键都具有两种尺寸,默认情况是Normal 就像上面图中的所有Button。另外一种就是Compact,我将它称为精简模式,只需通过IsCompact 属性即可实现。当IsCompact 设置为True 时,按键的Label 名称将自动隐藏,并且按键所占空间也会缩小。如下代码,将其中几个Button 设为IsCompact=True。上下两张图已经可以很明显的看出差别了。
<AppBarButton x:Uid="Camera" Icon="Camera" Label="Camera" IsCompact="True"/>
<AppBarToggleButton x:Uid="Suffle" Icon="Shuffle" Label="Shuffle" IsCompact="True"/>
<AppBarToggleButton x:Uid="Account" Icon="Account" Label="Account" IsCompact="True"/>
<AppBarButton x:Uid="Like" Icon="Like" Label="Like" IsCompact="True"/>
<AppBarButton x:Uid="Dislike" Icon="Dislike" Label="Dislike" IsCompact="True"/>

同时,按键的Icon 也提供了多种展现方式,上述Button 均为SymbolIcon 模式,除此之外还包括:
• SymbolIcon -- 基于符号
• FontIcon -- 基于文字
• BitmapIcon -- 基于图片
• PathIcon -- 基于路径图
具体用途,看了下面几个简单示例肯定就清楚了:
<AppBarButton Icon="Like" Label="SymbolIcon"/> <AppBarButton Label="BitmapIcon">
<AppBarButton.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/globe.png"/>
</AppBarButton.Icon>
</AppBarButton> <AppBarToggleButton Label="FontIcon">
<AppBarToggleButton.Icon>
<FontIcon FontFamily="Candara" Glyph="Σ"/>
</AppBarToggleButton.Icon>
</AppBarToggleButton> <AppBarToggleButton Label="PathIcon">
<AppBarToggleButton.Icon>
<PathIcon Data="F1 M 20,20L 24,10L 24,24L 5,24"/>
</AppBarToggleButton.Icon>
</AppBarToggleButton>

AppBar 就先讲到这里吧,下期再来看看CommandBar。
Windows 8.1 新增控件之 AppBar的更多相关文章
- Windows 8.1 新增控件之 DatePicker
大年初一来介绍一个简单易用的DatePicker 控件,这个控件是新增的?印象里很早就有了啊,Anyway来看看Windows 8.1 里的DataPicker 有什么功能吧. 先来看看这个代码,很简 ...
- Windows 8.1 新增控件之 Hyperlink
Hyperlink 控件应该不用过多介绍大家肯定十分清楚其作用,它的功能就像HTML中的<a href="">标签一样,只不过是在XAML中实现. 使用Hyperlin ...
- Windows 8.1 新增控件之 TimePicker
之前已经为大家介绍过DatePicker 控件的相关内容,有日期控件当然就得有时间控件,本篇将和各位一起了解TimePicker 的使用方法. 先来介绍一下ClockIdentifier 属性,默认情 ...
- Windows 8.1 新增控件之 CommandBar
上一篇为大家介绍了AppBar 的相关内容,本篇继续介绍CommandBar 的使用方法.与AppBar 相比而言,CommandBar 在开发使用方面较为单一,在按键布局上分为主控区(Primary ...
- Windows 8.1 新增控件之 MenuFlyout
开始这篇讲解前,我们先来温习一下Flyout 的内容,当触发应用中某个Button 时会有Flyout 出现提示用户该操作接下来将会发生什么.Flyout 简单来说就是一个轻量级信息提示需要用户确认或 ...
- Windows 8.1 新增控件之 Flyout
本篇为大家介绍Flyout 控件,Flyout 属于一种轻量级交互控件,可以支持信息提示或用户交互.与传统Dialog 控件不同的是Flyout 控件可通过直接点击对话框外部区域忽略. Flyout ...
- 重新想象 Windows 8.1 Store Apps (72) - 新增控件: AppBar, CommandBar
[源码下载] 重新想象 Windows 8.1 Store Apps (72) - 新增控件: AppBar, CommandBar 作者:webabcd 介绍重新想象 Windows 8.1 Sto ...
- Windows 8.1 应用再出发 - 几种新增控件(1)
Windows 8.1 新增的一些控件,分别是:AppBar.CommandBar.DatePicker.TimePicker.Flyout.MenuFlyout.SettingsFlyout.Hub ...
- Windows 8.1 应用再出发 (WinJS) - 几种新增控件(2)
上篇我们介绍了Windows 8.1 和 WinJS 中新增控件中的 AppBarCommand.BackButton.Hub.ItemContainer,本篇我们接着来介绍 NavBar.Repea ...
随机推荐
- 说说Angular中的$timeOut定时器
非常不幸的一点是,人们似乎常常将AngularJS中的$timeOut()函数看做是一个内置的.无须在意的函数.但是,如果你忘记了$timeOut()的回调函数将会造成非常不好的影响,你可能会因此遇 ...
- FileOutputStream VS FileWriter
当我们使用Java往文件写入数据的时候,我们有两种方式,使用FileOutputStream或FileWriter. FileOutputStream: File fout = new File(fi ...
- jQuery中find和filter的区别
本文来自:http://blog.csdn.net/woshixuye/article/details/7255260 这是jQuery里常用的2个方法. 他们2者功能是完全不同的,而初学者往往会被误 ...
- spring的定时任务配置
本文来源于:http://myspace1916.iteye.com/blog/1570707 也可参考:http://www.oschina.net/question/8676_9032 (个人只是 ...
- 欲哭无泪的@Autowired注入对象为NULL
欲哭无泪啊...一下午的时间就这么被浪费了...一个基于spring mvc和spring data jpa的小项目,当我写完一个controller的测试用例后,一运行却报空指针,跟了下是一个dao ...
- mysql 二进制文件增量备份
1.首先在my.cnf下添加二进制文件路径(windows下文件名称为my.ini) 在[mysqld]下添加 log-bin=mysql-bin 2.centos下默认安装mysql 5.6,数据默 ...
- AngularJS几个基础概念
作用域 应用的作用域是和应用的数据模型相关联的,同时作用域也是表达式执行的上下文.$scope对象是定义应用业务逻辑.控制器方法和视图属性的地方.作用域是视图和作用域之间的胶水.在应用将视图渲染并呈现 ...
- Remote Displayer for Android V1.2
VERSION LOG for Android Remote Displayer Features:The app allows you to see your Android device remo ...
- android代码优化----ListView中自定义adapter的封装(ListView的模板写法)
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...
- POJ1160 Post Office[序列DP]
Post Office Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18680 Accepted: 10075 Des ...