与众不同 windows phone (51) - 8.1 新增控件: DatePickerFlyout, TimePickerFlyout
作者:webabcd
介绍
与众不同 windows phone 8.1 之 新增控件
- DatePickerFlyout - 日期选取器控件
- TimePickerFlyout - 时间选取器控件
示例
1、演示 DatePickerFlyout 的应用
DatePickerFlyoutDemo.xaml
<Page
x:Class="Demo.Control.DatePickerFlyoutDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Demo.Control"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid>
<StackPanel Orientation="Vertical"> <Button Content="Show DatePicker" >
<Button.Flyout>
<!--
Title - 弹出框的标题
-->
<DatePickerFlyout x:Name="datePicker" Title="选择日期" DatePicked="datePicker_DatePicked" Closed="datePicker_Closed" />
</Button.Flyout>
</Button> <!--对于 DatePicker 控件来说,是 wp 和 windows 都支持的,详细说明参见:http://www.cnblogs.com/webabcd/archive/2014/05/12/3722733.html-->
<DatePicker Header="Date" Margin="0 10 0 0" /> <TextBlock Name="lblMsg" Margin="0 10 0 0" /> </StackPanel>
</Grid>
</Page>
DatePickerFlyoutDemo.xaml.cs
/*
* DatePickerFlyout - 日期选取器控件(wp only)
* ShowAtAsync(FrameworkElement target) - 弹出日期选取器控件
* Hide() - 隐藏弹出框
*
* DatePicked - 用户选择日期后(点击“完成”按钮)触发的事件
* Opening, Opened, Closed - 几个顾名思义的事件
*/ using System;
using Windows.Globalization;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation; namespace Demo.Control
{
public sealed partial class DatePickerFlyoutDemo : Page
{
public DatePickerFlyoutDemo()
{
this.InitializeComponent();
} protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Date - 当前显示的日期
datePicker.Date = DateTimeOffset.Now.AddMonths(); // MinYear - DatePicker 控件所允许选择的最小的年份
datePicker.MinYear = DateTimeOffset.Now.AddYears(-);
// MaxYear - DatePicker 控件所允许选择的最大的年份
datePicker.MaxYear = DateTimeOffset.Now.AddYears(); // YearVisible - 是否显示 year 选择框
datePicker.YearVisible = true;
// MonthVisible - 是否显示 month 选择框
datePicker.MonthVisible = true;
// DayVisible - 是否显示 day 选择框
datePicker.DayVisible = true; // CalendarIdentifier - DatePicker 控件所使用的日历系统(Gregorian, Hebrew, Hijri, Japanese, Julian, Korean, Taiwan, Thai, UmAlQura)
datePicker.CalendarIdentifier = CalendarIdentifiers.Gregorian; } // 用户点击了“完成”按钮后触发的事件
private void datePicker_DatePicked(DatePickerFlyout sender, DatePickedEventArgs args)
{
// e.OldDate - 原日期
// e.NewDate - 新日期
lblMsg.Text = args.NewDate.ToString("yyyy-MM-dd hh:mm:ss");
lblMsg.Text += Environment.NewLine;
} // 通过 DatePicked 事件和 Closed 事件的结合,可以判断出用户是否点击了“取消”按钮或者按了“返回键”
private void datePicker_Closed(object sender, object e)
{
lblMsg.Text += "closed";
lblMsg.Text += Environment.NewLine;
}
}
}
2、演示 TimePickerFlyout 的应用
TimePickerFlyoutDemo.xaml
<Page
x:Class="Demo.Control.TimePickerFlyoutDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Demo.Control"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid>
<StackPanel Orientation="Vertical"> <Button Content="Show TimePicker" >
<Button.Flyout>
<!--
Title - 弹出框的标题
-->
<TimePickerFlyout x:Name="timePicker" Title="选择时间" TimePicked="timePicker_TimePicked" Closed="timePicker_Closed" />
</Button.Flyout>
</Button> <!--对于 TimePicker 控件来说,是 wp 和 windows 都支持的,详细说明参见:http://www.cnblogs.com/webabcd/archive/2014/05/12/3722733.html-->
<TimePicker Header="Time" Margin="0 20 0 0" /> <TextBlock Name="lblMsg" Margin="0 10 0 0" /> </StackPanel>
</Grid>
</Page>
TimePickerFlyoutDemo.xaml.cs
/*
* TimePickerFlyout - 时间选取器控件(wp only)
* ShowAtAsync(FrameworkElement target) - 弹出时间选取器控件
* Hide() - 隐藏弹出框
*
* TimePicked - 用户选择时间后(点击“完成”按钮)触发的事件
* Opening, Opened, Closed - 几个顾名思义的事件
*/ using System;
using Windows.Globalization;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation; namespace Demo.Control
{
public sealed partial class TimePickerFlyoutDemo : Page
{
public TimePickerFlyoutDemo()
{
this.InitializeComponent();
} protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Time - TimePicker 控件当前显示的时间
timePicker.Time = new TimeSpan(, , ); // MinuteIncrement - 分钟选择框的分钟增量(0, 15, 30, 45)
timePicker.MinuteIncrement = ; // ClockIdentifier - 小时制式,ClockIdentifiers.TwelveHour(12HourClock),12 小时制
// timePicker.ClockIdentifier = ClockIdentifiers.TwelveHour; // ClockIdentifier - 小时制式,ClockIdentifiers.TwentyFourHour(24HourClock),24 小时制
timePicker.ClockIdentifier = ClockIdentifiers.TwentyFourHour;
} // 用户点击了“完成”按钮后触发的事件
private void timePicker_TimePicked(TimePickerFlyout sender, TimePickedEventArgs args)
{
// e.OldTime - 原时间
// e.NewTime - 新时间
lblMsg.Text = args.NewTime.ToString("c");
lblMsg.Text += Environment.NewLine;
} // 通过 TimePicked 事件和 Closed 事件的结合,可以判断出用户是否点击了“取消”按钮或者按了“返回键”
private void timePicker_Closed(object sender, object e)
{
lblMsg.Text += "closed";
lblMsg.Text += Environment.NewLine;
}
}
}
OK
[源码下载]
与众不同 windows phone (51) - 8.1 新增控件: DatePickerFlyout, TimePickerFlyout的更多相关文章
- 与众不同 windows phone (49) - 8.1 新增控件: 概述, ContentDialog, MapControl
[源码下载] 与众不同 windows phone (49) - 8.1 新增控件: 概述, ContentDialog, MapControl 作者:webabcd 介绍与众不同 windows p ...
- 与众不同 windows phone (50) - 8.1 新增控件: PickerFlyout, ListPickerFlyout
[源码下载] 与众不同 windows phone (50) - 8.1 新增控件: PickerFlyout, ListPickerFlyout 作者:webabcd 介绍与众不同 windows ...
- 与众不同 windows phone (52) - 8.1 新增控件: AutoSuggestBox, ListView, GridView, SemanticZoom
[源码下载] 与众不同 windows phone (52) - 8.1 新增控件: AutoSuggestBox, ListView, GridView, SemanticZoom 作者:webab ...
- Windows 8.1 应用再出发 - 几种新增控件(1)
Windows 8.1 新增的一些控件,分别是:AppBar.CommandBar.DatePicker.TimePicker.Flyout.MenuFlyout.SettingsFlyout.Hub ...
- Windows 8.1 应用再出发 - 几种新增控件(2)
本篇我们接着来介绍Windows 8.1 的新增控件,分别是:Flyout.MenuFlyout.SettingsFlyout.Hub 和 Hyperlink. 1. Flyout Flyout被称为 ...
- Windows 8.1 应用再出发 (WinJS) - 几种新增控件(2)
上篇我们介绍了Windows 8.1 和 WinJS 中新增控件中的 AppBarCommand.BackButton.Hub.ItemContainer,本篇我们接着来介绍 NavBar.Repea ...
- 重新想象 Windows 8.1 Store Apps (72) - 新增控件: AppBar, CommandBar
[源码下载] 重新想象 Windows 8.1 Store Apps (72) - 新增控件: AppBar, CommandBar 作者:webabcd 介绍重新想象 Windows 8.1 Sto ...
- 重新想象 Windows 8.1 Store Apps (73) - 新增控件: DatePicker, TimePicker
[源码下载] 重新想象 Windows 8.1 Store Apps (73) - 新增控件: DatePicker, TimePicker 作者:webabcd 介绍重新想象 Windows 8.1 ...
- 重新想象 Windows 8.1 Store Apps (74) - 新增控件: Flyout, MenuFlyout, SettingsFlyout
[源码下载] 重新想象 Windows 8.1 Store Apps (74) - 新增控件: Flyout, MenuFlyout, SettingsFlyout 作者:webabcd 介绍重新想象 ...
随机推荐
- drupal module 自定义
01 <?php function mytracer_menu() { $items = array(); $items['admin/config/mytracer'] = array( 't ...
- RxJava基本流程和lift源码分析
1.subscribe过程 2.lift过程
- Mac mongodb 配置安装
简单总结就几条,比较简单配置mongodb. 1,首先下载安装包:百度云下载地址 2,下载之后解压到自己常放的工作目录下,然后开始配置一下你的Mac环境 vim ~/.bash_profile 添加m ...
- linq join多字段
from VS in m2db.Inf_VehicleSale join RS1 in m2db.His_RecSale on new { VS.vehicleCode, auctionCode=VS ...
- 跟随标准与Webkit源码探究DOM -- 获取元素之getElementsByClassName
按照类名获取元素 -- getElementsByClassName(HTML5) 标准 WHATWG 在Document与Element上均有定义,原型 HTMLCollection getElem ...
- iOS 7.1 安装 企业应用 提示 无法下载应用程序
首先这种情况排除https影响,这个就不提了.请自行查询iOS https 部署. 其次系统版本是iOS 7.1,之后的版本安装都没问题. 说下我是怎么发现问题的,我找了个真机,发现直接调试提示bun ...
- 封装Js事件代理方法
// 封装事件代理 function delegateEvent(element, tag, event, listener) { // 判断是否支持addEventlistener if(eleme ...
- MySQL单机load过高问题讨论
有一个朋友问我: "hi,我想问下你们遇到单机load过高的情况 采取什么紧急措施啊?" 我问他是不是mysql db server? 他说是. 我给他如下建议: 1 先看下是不是 ...
- apple Swift教程大全,希望对你有帮助!
1)apple Swift编程入门文档- http://gashero.iteye.com/blog/2075324 一位大神写的关于Swift的一些介绍和简单的使用,里面介绍了Swift和其他语言的 ...
- bootstrap插件学习-bootstrap.scrollspy.js
先看bootstrap.dropdown.js的结构 function ScrollSpy(){} //构造函数 ScrollSpy.prototype = {} //构造器的原型 $.fn.scro ...