Windows Phone 8.1 控件
如果你已经开始了 Windows Phone 8.1 的学习,就会发现许多在 8.0 下的控件在 8.1 中都发生了变化,以下就谈谈几个 8.1 下的新控件以及与 8.0 控件的改变。
1. TextBox, AutoSuggestBox
TextBox 终于有了 Header 属性,再也不用为 TextBox 写一堆 TextBlock 了。
<TextBox Header="TextBoxWithHeader"/>
当某些控件没有 Header 属性的时候,可以将 TextBlock 的 Style 绑定为 ControlHeaderTextBlockStyle,这样就可以与 TextBox 的 Header 样式相同了。
<TextBlock Text="TextBoxWithoutHeader" Style="{StaticResource ControlHeaderTextBlockStyle}"/>
<RadioButton Content="RadioButton"/>
界面为这样:

AutoSuggestBox 的使用则只需绑定 ItemsSource。
XAML:
<AutoSuggestBox x:Name="autoBox"
Header="AutoSuggestBox"
GotFocus="autoBox_GotFocus"
TextChanged="autoBox_TextChanged">
<AutoSuggestBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</AutoSuggestBox.ItemTemplate>
</AutoSuggestBox>
C#:
List<string> suggestions = new List<string>(){ "S1", "S2", "S3", "U1", "U2", "U3" };
private void autoBox_GotFocus(object sender, RoutedEventArgs e)
{
autoBox.ItemsSource = suggestions;
}
private void autoBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
{
string filter = sender.Text.ToUpper();
autoBox.ItemsSource = suggestions.Where(s => s.ToUpper().Contains(filter));
}
界面为这样:

2. MessageDialog, ContentDialog
刚学 8.1 遇到的第一个问题就是 MessageBox 不见了,其实它只是换成了 MessageDialog。
private async void messageDialogButton_Click(object sender, RoutedEventArgs e)
{
MessageDialog messageDialog = new MessageDialog("MessageBox --> MessageDialog", "MessageDialog");
await messageDialog.ShowAsync();
}
界面:

ContentDialog 则可以设置为部分或者全屏,或者直接在项目里新建一个 ContentDialog。
private async void partialDialogButton_Click(object sender, RoutedEventArgs e)
{
ContentDialog contentDialog = new ContentDialog();
contentDialog.FullSizeDesired = false;
contentDialog.Title = "Partial ContentDialog";
contentDialog.Content = "Partial";
await contentDialog.ShowAsync();
} private async void fullDialogButton_Click(object sender, RoutedEventArgs e)
{
ContentDialog contentDialog = new ContentDialog();
contentDialog.FullSizeDesired = true;
contentDialog.Title = "Full ContentDialog";
contentDialog.Content = "Full";
await contentDialog.ShowAsync();
} private async void customDialogButton_Click(object sender, RoutedEventArgs e)
{
CustomDialog customDialog = new CustomDialog();
await customDialog.ShowAsync();
}
界面:

Dialog 的显示都为异步方法。
3. Button
Button.Flyout.Flyout
<Button Content="Button.Flyout.Flyout"
HorizontalAlignment="Center">
<Button.Flyout>
<Flyout>
<StackPanel HorizontalAlignment="Center">
<TextBlock Text="Button.Flyout"
FontSize="40"/>
<Button Content="OK"
HorizontalAlignment="Center"/>
</StackPanel>
</Flyout>
</Button.Flyout>
</Button>
界面:

Button.Flyout.MenuFlyout
<Button Content="Button.Flyout.MenuFlyout"
HorizontalAlignment="Center">
<Button.Flyout>
<MenuFlyout>
<MenuFlyoutItem Text="MenuFlyoutItem"/>
<ToggleMenuFlyoutItem Text="ToggleMenuFlyoutItem"/>
</MenuFlyout>
</Button.Flyout>
</Button>
界面:

4. BottomAppBar
之前的 ApplicationBar 更换成了 BottomAppBar。
<Page.BottomAppBar>
<CommandBar>
<CommandBar.PrimaryCommands>
<AppBarButton Icon="Accept" Label="Accept"/>
<AppBarButton Icon="Cancel" Label="Cancel"/>
</CommandBar.PrimaryCommands>
<CommandBar.SecondaryCommands>
<AppBarButton Icon="Help" Label="Help"/>
</CommandBar.SecondaryCommands>
</CommandBar>
</Page.BottomAppBar>
界面:

还有就是 AppBarButton 同样支持 Flyout。
5. StatusBar
之前的 SystemTray 更改为 StatusBar,并且只能通过 C# 代码控制,不能用 XAML 控制。
private async void Button_Click(object sender, RoutedEventArgs e)
{
Windows.UI.ViewManagement.StatusBar statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
await statusBar.HideAsync();
}
界面:

6. Magic Number:10
在 8.0 时代,Magic Number 为 12,也就是间距最好都设为 12 的倍数,或者 6。
但到了 8.1,微软将 12 改成了 10。
Windows Phone 8.1 控件的更多相关文章
- [深入浅出Windows 10]分屏控件(SplitView)
4.18 分屏控件(SplitView) 分屏控件(SplitView)是Windows 10新增的控件类型,也是Windows 10通用应用程序主推的交互控件,通常和一个汉堡按钮搭配作为一种抽屉式菜 ...
- 深入Windows窗体原理及控件重绘技巧
之前有学MFC的同学告诉我觉得Windows的控件重绘难以理解,就算重绘成功了还是有些地方不明白,我觉得可能很多人都有这样的问题,在这里我从Windows窗体的最基本原理来讲解,如果你有类似的疑惑希望 ...
- Windows phone 自定义用户控件(UserControl)——ColorPicker
编码前 学习Windows phone自定义用户控件,在<WPF编程宝典>学习的小例子.并根据windows phone稍微的不同,做了点修改.ColorPicker(颜色拾取器):拥有三 ...
- Windows Phone - 按钮/button 控件
System.Windows.Controls.Button button控件一.button控件的各种样式的展示可以通过 …… 来给控件定义公共的样式调用样式的方法:在Button控件上添加样式 ...
- windows下注册ocx控件
OCX 是对象类别扩充组件(Object Linking and Embedding (OLE) Control Extension):是可执行的文件的一种,但不可直接被执行: 是 ocx 控件的扩展 ...
- Windows高DPI系列控件(二) - 柱状图
目录 一.QCP 二.效果展示 三.高DPI适配 1.自定义柱状图 2.新的柱状图 3.测试代码 四.相关文章 原文链接:Windows高DPI系列控件(二) - 柱状图 一.QCP QCP全称QCu ...
- 【Windows编程】系列第二篇:Windows SDK创建基本控件
在Win32 SDK环境下,怎么来创建常用的那些基本控件呢?我们知道如果用MFC,简单的拖放即可完成大多数控件的创建,但是我们既然是用Windows SDK API编程,当然是从根上解决这个问题,实际 ...
- Windows Phone 四、控件模版
控件模版的概念 Windows Phone中每一个控件都有一个默认的模版,用于描述控件的内部组成结构和外观样式 相对于原本的样式外观操作,自定义模版的可自定义性更强 最基本的重写控件模版 <Gr ...
- Windows 8.1 新增控件之 Hyperlink
Hyperlink 控件应该不用过多介绍大家肯定十分清楚其作用,它的功能就像HTML中的<a href="">标签一样,只不过是在XAML中实现. 使用Hyperlin ...
- Windows 8.1 新增控件之 TimePicker
之前已经为大家介绍过DatePicker 控件的相关内容,有日期控件当然就得有时间控件,本篇将和各位一起了解TimePicker 的使用方法. 先来介绍一下ClockIdentifier 属性,默认情 ...
随机推荐
- golang pipe
===============golang pipe============== package main import ( "fmt" "io" ) func ...
- 《一》File 类的介绍
File 类:文件和目录路径名的抽象表示. 注意:File 类只能操作文件的属性,文件的内容是不能操作的. 1.File 类的字段 我们知道,各个平台之间的路径分隔符是不一样的. ①.对于UN ...
- 判断移动端跳转,从移动端来的不跳转。利用localStorage保存状态,window.location.pathname跳转不同的url
手机访问 www.yourdomain.com 跳转,从m.yourdomain.com来的不跳转. 访问www.yourdomain.com/category8, 跳转到m.yourdomain.c ...
- STM32 输入捕获的脉冲宽度及频率计算
输入捕获模式可以用来测量脉冲宽度或者测量频率.STM32 的定时器,除了 TIM6 和 TIM7,其他定时器都有输入捕获功能.以下是对脉冲宽度及频率的计算. 1.脉冲宽度 如下图所示,采集该高电平脉冲 ...
- arcgis webapp builder 安装试用
ArcGIS WebApp Builder 是针对开发者的,用于高速构建基于HTML5/Javascript 技术的美观的 Web应用的一个工具. 用过Flex版本号的AppBuilder应该非常清楚 ...
- javascript: with 表单验证
<html> <head> <script type="text/javascript"> function validate_required ...
- Spark SQL概念学习系列之DataFrame与RDD的区别
不多说,直接上干货! DataFrame的推出,让Spark具备了处理大规模结构化数据的能力,不仅比原有的RDD转化方式更加简单易用,而且获得了更高的计算性能.Spark能够轻松实现从MySQL到Da ...
- import 与export详解
ES6 1.export default 其他模块加载该模块时,import命令可以为该匿名函数指定任意名字. 如: import Vue from 'vue' vue里面的第三方模块都是用了这个 使 ...
- c++ 常识
1) 功能:格式化字符串输出 说明:format指定输出格式,后面跟要输出的变量 目前printf支持以下格式: %c 单个字符 ...
- amazeui学习笔记--css(常用组件2)--面包屑导航Breadcrumb
amazeui学习笔记--css(常用组件2)--面包屑导航Breadcrumb 一.总结 1.am-breadcrumb:用am-breadcrumb来声明面包屑导航控件,.am-breadcrum ...