与众不同 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 介绍重新想象 ...
随机推荐
- UICollectionView瀑布流的实现原理(转)
http://ios.jobbole.com/85689/ 和使用 UIScollView 创刊一个瀑布流是一样的方式 7cc829d3gw1f4nq2oc09zj20j00hvq90.jpg 我的 ...
- [Core Javascirpt] Basic Metaprogramming: Dynamic Method
Somehow it looks like reflect in Java. For example: We define an mothod on the Object, it called def ...
- [GraphQL] Use Arguments in a GraphQL Query
In GraphQL, every field and nested object is able to take in arguments of varying types in order to ...
- 少睡与吸烟影响IQ
导读:据英国<每日邮报>报道,根据科学家一项最新研究发现,一晚的糟糕睡眠,对大脑可能产生很大损害,就等同头部遭到了一次严重的撞击.长期睡眠不好会造成智力下降,请看[科学探索]揭秘: ...
- javascript不用new关键字创建对象示例
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- LNMP软件安装所在的目录详细
LNMP相关软件安装目录Nginx 目录: /usr/local/nginx/MySQL 目录 : /usr/local/mysql/MySQL数据库所在目录:/usr/local/mysql/var ...
- Gamma校正与线性工作流
1 Gamma校正是什么?8位亮度值x(0-1)经过x^0.45的一个提亮过程. 2 为什么需要Gamma校正 人的眼睛是以非线性方式感知亮度,在自然界中,人感觉到的一半亮度其实只有全部能量的0.2, ...
- java对过反射调用方法
public class InvokeTester { public InvokeTester() { } String str; public InvokeTester(String str) ...
- Mac OS X Tips
命令行查看Mac OS X版本 $ sw_vers ProductName: Mac OS X ProductVersion: BuildVersion: 14D131 Mac OS X截图 不要使用 ...
- C#连接mysql数据库插入数据后获取自增长主键ID值
From: http://blog.csdn.net/zbc496218/article/details/51082983 MySqlConnection conn = new MySqlConnec ...