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 ...
随机推荐
- iOS 学习 - 4.存储聊天记录
主要是用sqlite3来存储聊天记录 先导入sqlite3.dylib, 点 Add Other,同时按住shift+command+G, 在弹出的Go to the folder中输入/usr/li ...
- store 加载异常处理与加载信息提示
var msgTip = ''; // 一定要定义在使用前,且定义为全局变量 /--------------------------------store--------------------- ...
- (视频) 《快速创建网站》 3.1 WordPress 数据导入
本文是<快速创建网站>系列的第5篇,如果你还没有看过之前的内容,建议你点击以下目录中的章节先阅读其他内容再回到本文. 访问本系列目录,请点击:http://devopshub.cn/tag ...
- jQuery添加options点击事件并传值
说明: 根据选择不同店铺选项,上送不同id值,展示不同商品列表 var formStr = "{'supplierId':'供应链企业|%-jm-sprt-%|93794498-3'}& ...
- MVC 多语言记录1 设置默认的ResourceType
http://stackoverflow.com/questions/3260748/default-resource-for-data-annotations-in-asp-net-mvc Add ...
- Managed DirectX中的DirectShow应用(简单Demo及源码)
阅读目录 介绍 准备工作 环境搭建 简单Demo 显示效果 其他 Demo下载 介绍 DirectX是Microsoft开发的基于Windows平台的一组API,它是为高速的实时动画渲染.交互式音乐和 ...
- 烂泥:rsync配置文件详解
本文由秀依林枫提供友情赞助,首发于烂泥行天下. 对于rsync服务器来说,最重要和复杂的就是它的配置了.rsync服务器的配置文件为/etc/rsyncd.conf,其控制认证.访问.日志记录等等. ...
- Android系统自带样式(android:theme)详解-(转)
android:theme="@android:style/Theme.Dialog" : Activity显示为对话框模式 android:theme="@androi ...
- docker-5 docker仓库
docker部署环境:CentOS release 6.5 (Final) Docker配置文件:/etc/sysconfig/docker 重要参数解释: -H 表示Docker Daemon绑定 ...
- position&containing block
一.包含块(Containing Block) 要讲position,首先就涉及到一个概念:包含块. 1.包含块介绍 包含块简单理解就是一个定位参考块,就是"大盒子里套小盒子"中那 ...