Windows 8.1 新增控件之 Flyout
本篇为大家介绍Flyout 控件,Flyout 属于一种轻量级交互控件,可以支持信息提示或用户交互。与传统Dialog 控件不同的是Flyout 控件可通过直接点击对话框外部区域忽略。
Flyout 控件一般常与Button 结合使用,所以Button 控件默认增加了Flyout 属性,当使用Flyout 属性后,点击Button 时就会自动显示Flyout 内容,如下代码所示:
<Button Content="Delete Files">
<Button.Flyout>
<Flyout>
<StackPanel>
<TextBlock FontSize="15" Text="All the files will be deteled, Are you sure?" />
<Button Content="Yes, delete all!"/>
</StackPanel>
</Flyout>
</Button.Flyout>
</Button>
在Flyout 中仍然可以按需要添加各种控件,例如TextBlock、Button等。运行点击“Delete Files”按钮后,Flyout 内容将自动显示,如下图:
对于非Button 控件如何使用Flyout 呢,可以利用FlyoutBase.AttachedFlyout 属性为FrameworkElement 对象添加Flyout 功能,当然需要为该控件增加相应的触发事件来启动Flyout 功能。如下代码:
<TextBox Width="500" HorizontalAlignment="Left" GotFocus="TextBox_GotFocus">
<FlyoutBase.AttachedFlyout>
<Flyout>
<TextBlock Text="You can input 50 words here."/>
</Flyout>
</FlyoutBase.AttachedFlyout>
</TextBox>
private void TextBox_GotFocus(object sender, RoutedEventArgs e)
{
FrameworkElement element = sender as FrameworkElement;
if (element != null)
{
FlyoutBase.ShowAttachedFlyout(element);
}
}
运行效果如下图:
除此之外,也可以将Flyout 定义为StaticResource 供多种控件共享使用。
<Page.Resources>
<Flyout x:Key="FlyoutResources">
<StackPanel>
<TextBlock Text="This is a Flyout."/>
</StackPanel>
</Flyout>
</Page.Resources> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Margin="50" Orientation="Horizontal" VerticalAlignment="Top">
<Button Content="Click Button" Flyout="{StaticResource FlyoutResources}"/>
<TextBox FlyoutBase.AttachedFlyout="{StaticResource FlyoutResources}" Margin="50,20"
Height="20" Width="150" HorizontalAlignment="Left" GotFocus="TextBox_GotFocus"/>
</StackPanel>
</Grid>
Windows 8.1 新增控件之 Flyout的更多相关文章
- Windows 8.1 新增控件之 AppBar
Windows 8.1 与Windows 8 相比已经有了很多改进,从ITPro 角度这篇文章<What's New in Windows 8.1>已经表述的很详细.对开发者来说,最明显的 ...
- Windows 8.1 新增控件之 DatePicker
大年初一来介绍一个简单易用的DatePicker 控件,这个控件是新增的?印象里很早就有了啊,Anyway来看看Windows 8.1 里的DataPicker 有什么功能吧. 先来看看这个代码,很简 ...
- Windows 8.1 新增控件之 Hyperlink
Hyperlink 控件应该不用过多介绍大家肯定十分清楚其作用,它的功能就像HTML中的<a href="">标签一样,只不过是在XAML中实现. 使用Hyperlin ...
- Windows 8.1 新增控件之 MenuFlyout
开始这篇讲解前,我们先来温习一下Flyout 的内容,当触发应用中某个Button 时会有Flyout 出现提示用户该操作接下来将会发生什么.Flyout 简单来说就是一个轻量级信息提示需要用户确认或 ...
- Windows 8.1 新增控件之 TimePicker
之前已经为大家介绍过DatePicker 控件的相关内容,有日期控件当然就得有时间控件,本篇将和各位一起了解TimePicker 的使用方法. 先来介绍一下ClockIdentifier 属性,默认情 ...
- Windows 8.1 新增控件之 CommandBar
上一篇为大家介绍了AppBar 的相关内容,本篇继续介绍CommandBar 的使用方法.与AppBar 相比而言,CommandBar 在开发使用方面较为单一,在按键布局上分为主控区(Primary ...
- 重新想象 Windows 8.1 Store Apps (74) - 新增控件: Flyout, MenuFlyout, SettingsFlyout
[源码下载] 重新想象 Windows 8.1 Store Apps (74) - 新增控件: Flyout, MenuFlyout, SettingsFlyout 作者:webabcd 介绍重新想象 ...
- 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被称为 ...
随机推荐
- android 界面设计基本知识Ⅱ
上一章讲述了Android界面设计时,一些基本控件的使用,本章主要讲述自定义控件,Fragment和Headler线程机制. 1.自定义控件 (1)基本知识 dp.sp和dx px:像素点 ...
- 在SQL2008中使用XML应对不确定结构的参数
目的:统一接口,当数据结构发生变化时,前后端业务接口不发生变化,由业务具体解析结构. 规则:确定的接口用参数表(多行提交),不确定的参数用XML DECLARE @r TABLE ( ...
- thinkphp5命名规范
类的命名采用驼峰法,并且首字母大写.如:User.UserType[不需要加后缀.如IndexController是没必要的,应当直接为Index.接口或者抽象类也保持这个规范] 属性命名采用驼峰法, ...
- 个人作业week-1-14061195
软件: 根据维基百科, The first theory about software—prior to creation of computers as we know them today—was ...
- php中的cookie用法
cookie和session都可以暂时保存在多个页面中使用的变量,但是它们有本质的差别. cookie存放在客户端浏览器中,session保存在服务器上.它们之间的联系是session ID一般保存在 ...
- jQuery简单入门(五)
5.Ajax应用 在jQuery中$ajax()方法属于最底层的方法,第二层是load().$.get().$.post(),第三层是$.getScript()和 $.getJSON():下面根据使用 ...
- 烂泥:学习mysql的binlog配置
本文由秀依林枫提供友情赞助,首发于烂泥行天下. 1.基础知识 日志是把数据库的每一个变化都记载到一个专用的文件里,这种文件就叫做日志文件.mysql默认只开启错误日志,因为过多的日志将会影响系统的处理 ...
- x01.Game.CubeRun: 风一样的女子
1.题解 小孩学英语比较有意思,Monkey three => 猴三,风一样的女子 => 风 Girl.诸如此类不是重点,重点是一花一世界,一草一天堂.花花草草,纷纷扰扰.大千世界,当别具 ...
- openwrt修改flash大小
前言 默认openwrt trunk编译出来的flash大小为8M,但是我们手上的板子可能flash大小更大,本文以MT7620a为例,将其flash大小由8M修改为16M或者32M 增加dts文件 ...
- PHP正确的使用复数
<?php // 正确地显示复数 if(!function_exists('_plurals_format')) { /** * 正确的使用复数 * @access public * @auth ...