背水一战 Windows 10 (105) - 通知(Toast): 带按钮的 toast, 带输入的 toast(文本输入框,下拉选择框)
作者:webabcd
介绍
背水一战 Windows 10 之 通知(Toast)
- 带按钮的 toast
- 带输入的 toast(文本输入框,下拉选择框)
示例
1、本例用于演示如何弹出带按钮的 toast
Notification/Toast/ActionButton.xaml
<Page
x:Class="Windows10.Notification.Toast.ActionButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Notification.Toast"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="10 0 10 10"> <Button Name="buttonShowToast1" Content="显示 toast(文本按钮)" Click="buttonShowToast1_Click" Margin="5" /> <Button Name="buttonShowToast2" Content="显示 toast(图文按钮)" Click="buttonShowToast2_Click" Margin="5" /> </StackPanel>
</Grid>
</Page>
Notification/Toast/ActionButton.xaml.cs
/*
* 本例用于演示如何弹出带按钮的 toast
* 单击 toast 激活 app 后(前台方式激活),如何获取相关信息请参见 Demo.xaml.cs 中的代码
*
*
* 本例 xml 说明:
* activationType - 通过点击 toast 激活 app 时的激活方式,foreground 代表前台方式激活
* launch - 通过点击 toast 激活 app 时,传递给 app 的参数(通过按钮激活时,此参数无效)
* template - 在 uwp 中就 ToastGeneric 一种模板
* text - 每一个新的 text 会另起一行,一行显示不下会自动换行,第一个 text 会高亮显示,最多显示 5 行文本
* action - 按钮,最多显示 5 个按钮
* content - 按钮上显示的文本
* activationType - 单击此按钮激活 app 时的激活方式,foreground 代表前台方式激活
* arguments - 单击此按钮激活 app 时,传递给 app 的参数
* imageUri - 图文按钮上显示的图标
*/ using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; namespace Windows10.Notification.Toast
{
public sealed partial class ActionButton : Page
{
public ActionButton()
{
this.InitializeComponent();
} // 弹出 toast 通知(文本按钮)
private void buttonShowToast1_Click(object sender, RoutedEventArgs e)
{
// 清除本 app 的之前的全部 toast 通知
// ToastNotificationManager.History.Clear(); string toastXml = @"
<toast activationType='foreground' launch='Notification-Toast-ActionButton-Arguments 1'>
<visual>
<binding template='ToastGeneric'>
<text>toast - title</text>
<text>""Hololens""引领技术革命浪潮传统的人机交互,主要是通过键盘和触摸,包括并不能被精确识别的语音等。""Hololens""的出现,则给新一代体验更好的人机交互指明道路,并现实了设备的小型化和便携化。</text>
</binding>
</visual>
<actions>
<action content='确认' activationType='foreground' arguments='Notification-Toast-ActionButton-Arguments 1 confirm'/>
<action content='取消' activationType='foreground' arguments='Notification-Toast-ActionButton-Arguments 1 cancel' imageUri='Assets/StoreLogo.png' />
</actions>
</toast>"; XmlDocument toastDoc = new XmlDocument();
toastDoc.LoadXml(toastXml); ToastNotification toastNotification = new ToastNotification(toastDoc);
ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier();
toastNotifier.Show(toastNotification);
} // 弹出 toast 通知(图文按钮)
private void buttonShowToast2_Click(object sender, RoutedEventArgs e)
{
// 清除本 app 的之前的全部 toast 通知
// ToastNotificationManager.History.Clear(); string toastXml = @"
<toast activationType='foreground' launch='Notification-Toast-ActionButton-Arguments 2'>
<visual>
<binding template='ToastGeneric'>
<text>toast - title</text>
<text>""Hololens""引领技术革命浪潮传统的人机交互,主要是通过键盘和触摸,包括并不能被精确识别的语音等。""Hololens""的出现,则给新一代体验更好的人机交互指明道路,并现实了设备的小型化和便携化。</text>
</binding>
</visual>
<actions>
<action content='确认' activationType='foreground' arguments='Notification-Toast-ActionButton-Arguments 2 confirm' imageUri='Assets/StoreLogo.png' />
<action content='取消' activationType='foreground' arguments='Notification-Toast-ActionButton-Arguments 2 cancel' imageUri='Assets/StoreLogo.png' />
</actions>
</toast>"; XmlDocument toastDoc = new XmlDocument();
toastDoc.LoadXml(toastXml); ToastNotification toastNotification = new ToastNotification(toastDoc);
ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier();
toastNotifier.Show(toastNotification);
}
}
}
2、本例用于演示如何弹出带输入的 toast(文本输入框,下拉选择框)
Notification/Toast/ActionInput.xaml
<Page
x:Class="Windows10.Notification.Toast.ActionInput"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Notification.Toast"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="10 0 10 10"> <Button Name="buttonShowToast1" Content="显示 toast(文本输入框)" Click="buttonShowToast1_Click" Margin="5" /> <Button Name="buttonShowToast2" Content="显示 toast(文本输入框与快速应答)" Click="buttonShowToast2_Click" Margin="5" /> <Button Name="buttonShowToast3" Content="显示 toast(下拉选择框)" Click="buttonShowToast3_Click" Margin="5" /> </StackPanel>
</Grid>
</Page>
Notification/Toast/ActionInput.xaml.cs
/*
* 本例用于演示如何弹出带输入的 toast(文本输入框,下拉选择框)
* 单击 toast 激活 app 后(前台方式激活),如何获取相关信息请参见 Demo.xaml.cs 中的代码
*
*
* 本例 xml 说明:
* activationType - 通过点击 toast 激活 app 时的激活方式,foreground 代表前台方式激活
* launch - 通过点击 toast 激活 app 时,传递给 app 的参数(通过按钮激活时,此参数无效)
* template - 在 uwp 中就 ToastGeneric 一种模板
* text - 每一个新的 text 会另起一行,一行显示不下会自动换行,第一个 text 会高亮显示,最多显示 5 行文本
* input - 输入框,最多显示 5 个输入框
* type - text 文本输入框;selection 下拉选择框(最多 5 条选项)
* id - 标识
* title - 输入框上显示的标题
* defaultInput - 输入框内显示的默认内容
* placeHolderContent - 输入框内显示的 placeHolder
* action - 按钮
* hint-inputId - 用于快速应答场景,指定快速应答的 input 的 id
* 说明:当指定的 input 无内容时则按钮不可点击,当指定的 input 有内容时则按钮可点击(也可以通过快捷键 ctrl + enter 发送)
*
*
* 注:只有通过 toast 中的按钮激活 app 时,input 中的内容才会被传递(通过点击 toast 激活 app 时,input 中的内容不会被传递)
*/ using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; namespace Windows10.Notification.Toast
{
public sealed partial class ActionInput : Page
{
public ActionInput()
{
this.InitializeComponent();
} // 弹出 toast 通知(文本输入框)
private void buttonShowToast1_Click(object sender, RoutedEventArgs e)
{
// 清除本 app 的之前的全部 toast 通知
// ToastNotificationManager.History.Clear(); string toastXml = @"
<toast activationType='foreground' launch='Notification-Toast-ActionInput-Arguments 1'>
<visual>
<binding template='ToastGeneric'>
<text>toast - title</text>
<text>""Hololens""引领技术革命浪潮传统的人机交互,主要是通过键盘和触摸,包括并不能被精确识别的语音等。""Hololens""的出现,则给新一代体验更好的人机交互指明道路,并现实了设备的小型化和便携化。</text>
</binding>
</visual>
<actions>
<input type='text' id='message1' title='title1' />
<input type='text' id='message2' title='title2' defaultInput='defaultInput'/>
<input type='text' id='message3' title='title3' placeHolderContent='placeHolderContent'/>
<action content='确认' activationType='foreground' arguments='Notification-Toast-ActionInput-Arguments 1 confirm'/>
</actions>
</toast>"; XmlDocument toastDoc = new XmlDocument();
toastDoc.LoadXml(toastXml); ToastNotification toast = new ToastNotification(toastDoc);
ToastNotificationManager.CreateToastNotifier().Show(toast);
} // 弹出 toast 通知(文本输入框与快速应答)
private void buttonShowToast2_Click(object sender, RoutedEventArgs e)
{
// 清除本 app 的之前的全部 toast 通知
// ToastNotificationManager.History.Clear(); string toastXml = @"
<toast activationType='foreground' launch='Notification-Toast-ActionInput-Arguments 2'>
<visual>
<binding template='ToastGeneric'>
<text>toast - title</text>
<text>""Hololens""引领技术革命浪潮传统的人机交互,主要是通过键盘和触摸,包括并不能被精确识别的语音等。""Hololens""的出现,则给新一代体验更好的人机交互指明道路,并现实了设备的小型化和便携化。</text>
</binding>
</visual>
<actions>
<input id='message' type='text' />
<action content='确认' activationType='foreground' arguments='Notification-Toast-ActionInput-Arguments 2 confirm'
hint-inputId='message' />
</actions>
</toast>"; XmlDocument toastDoc = new XmlDocument();
toastDoc.LoadXml(toastXml); ToastNotification toast = new ToastNotification(toastDoc);
ToastNotificationManager.CreateToastNotifier().Show(toast);
} // 弹出 toast 通知(下拉选择框)
private void buttonShowToast3_Click(object sender, RoutedEventArgs e)
{
// 清除本 app 的之前的全部 toast 通知
// ToastNotificationManager.History.Clear(); string toastXml = @"
<toast activationType='foreground' launch='Notification-Toast-ActionInput-Arguments 3'>
<visual>
<binding template='ToastGeneric'>
<text>toast - title</text>
<text>""Hololens""引领技术革命浪潮传统的人机交互,主要是通过键盘和触摸,包括并不能被精确识别的语音等。""Hololens""的出现,则给新一代体验更好的人机交互指明道路,并现实了设备的小型化和便携化。</text>
</binding>
</visual>
<actions>
<input id ='select' type='selection' defaultInput='2'>
<selection id='1' content='1天' />
<selection id='2' content='2天' />
<selection id='3' content='3天' />
<selection id='4' content='4天' />
<selection id='5' content='5天' />
</input>
<action content='确认' activationType='foreground' arguments='Notification-Toast-ActionInput-Arguments 3 confirm'/>
</actions>
</toast>"; XmlDocument toastDoc = new XmlDocument();
toastDoc.LoadXml(toastXml); ToastNotification toast = new ToastNotification(toastDoc);
ToastNotificationManager.CreateToastNotifier().Show(toast);
}
}
}
OK
[源码下载]
背水一战 Windows 10 (105) - 通知(Toast): 带按钮的 toast, 带输入的 toast(文本输入框,下拉选择框)的更多相关文章
- 背水一战 Windows 10 (107) - 通知(Toast): 提示音, 特定场景
[源码下载] 背水一战 Windows 10 (107) - 通知(Toast): 提示音, 特定场景 作者:webabcd 介绍背水一战 Windows 10 之 通知(Toast) 提示音 特定场 ...
- 背水一战 Windows 10 (106) - 通知(Toast): 通过 toast 打开协议, 通过 toast 选择在指定的时间之后延迟提醒或者取消延迟提醒
[源码下载] 背水一战 Windows 10 (106) - 通知(Toast): 通过 toast 打开协议, 通过 toast 选择在指定的时间之后延迟提醒或者取消延迟提醒 作者:webabcd ...
- 背水一战 Windows 10 (104) - 通知(Toast): 纯文本 toast, 短时 toast, 长时 toast, 图文 toast
[源码下载] 背水一战 Windows 10 (104) - 通知(Toast): 纯文本 toast, 短时 toast, 长时 toast, 图文 toast 作者:webabcd 介绍背水一战 ...
- 背水一战 Windows 10 (103) - 通知(Toast): 基础, 按计划显示 toast 通知
[源码下载] 背水一战 Windows 10 (103) - 通知(Toast): 基础, 按计划显示 toast 通知 作者:webabcd 介绍背水一战 Windows 10 之 通知(Toast ...
- 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButton, AppBarButton, AppBarToggleButton
[源码下载] 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButt ...
- 背水一战 Windows 10 (111) - 通知(Tile): secondary tile 模板之图片, secondary tile 模板之分组
[源码下载] 背水一战 Windows 10 (111) - 通知(Tile): secondary tile 模板之图片, secondary tile 模板之分组 作者:webabcd 介绍背水一 ...
- 背水一战 Windows 10 (112) - 通知(Badge): application 的 badge 通知, secondary 的 badge 通知, 轮询服务端以更新 badge 通知
[源码下载] 背水一战 Windows 10 (112) - 通知(Badge): application 的 badge 通知, secondary 的 badge 通知, 轮询服务端以更新 bad ...
- 背水一战 Windows 10 (110) - 通知(Tile): secondary tile 模板之基础, secondary tile 模板之文本
[源码下载] 背水一战 Windows 10 (110) - 通知(Tile): secondary tile 模板之基础, secondary tile 模板之文本 作者:webabcd 介绍背水一 ...
- 背水一战 Windows 10 (109) - 通知(Tile): 按计划显示 tile 通知, 轮询服务端以更新 tile 通知
[源码下载] 背水一战 Windows 10 (109) - 通知(Tile): 按计划显示 tile 通知, 轮询服务端以更新 tile 通知 作者:webabcd 介绍背水一战 Windows 1 ...
随机推荐
- NET CORE 2.0发布在IIS上提示502.5错误
在装了WindowsHosting和NET CORE SDK后,如果没有重启服务器,访问站点报以上错误,解决办法要么重启,要么执行以下两条命令: net stop was /y net start w ...
- Python入门day04_函数与装饰器
一.函数入门 什么是函数: # 函数:函数是一系列代码的集,用来完成特定功能的代码块,类似于工具,可以重复不但的去使用 为什么要有函数: # 优点:# 1. 避免代码的冗余 # 2. 让程序代码结构更 ...
- java 坑总结
1.Cannot find current proxy: Set 'exposeProxy' property on Advised to 'true' to make it available. 解 ...
- 使用Fiddle对夜神模拟器进行抓包的设置
注意: 设置完后, 不开启 Fiddle 的话,模拟器就不能上网了. 可以通过再把网络配置 改回去 就可以恢复网络正常访问了 一.配置Fiddle参数设置 1.Tools->Options 2 ...
- super()调用父类构造方法
super()表示调用父类中的构造方法 1.子类继承父类,子类的构造方法的第一行,系统会默认编写super(),在调用子类的构造方法时,先调用父类的无参数构造方法 2.如果父类中只有有参数构造方法,那 ...
- s3c2440 nandflash 初始化
1.什么是 nandflash ? FLASH闪存 闪存的英文名称是"Flash Memory",一般简称为"Flash",它属于内存器件的一种,是一种非易失性 ...
- [总结]给pcDuino v2编译Linux kernel
1.版本问题 推荐选择pcdunio提供的官方的kernel. 当然可以选用www.github.com/linux-sunxi 中的kernel,不过有很多驱动都用不了包括arduino. 我尝试了 ...
- 通过PRINT过程制作报表
通过PRINT过程制作报表 PRINT过程是SAS中用于输出数据集内容的最简单常用的过程,它可将选择的观测和字段以简单的矩形表格形式输出. 1.1 制作简单报表 使用PRINT过程最简单的语法形式如下 ...
- 人工智能&物联网开发的目录
走进嵌入式开发的世界,企业级项目课程让你达到企业嵌入式应用开发要求.名师在线答疑,解决疑难.科学评测体系,系统评估学习.核心项目实........ 30 门课程 241小时12分钟 824 人学习 学 ...
- 利用clonezilla克隆、还原CentOS整个系统
实现目的:全盘备份CentOS 6.0系统到U盘或者到移动硬盘 操作步骤: 1.制作再生龙镜像启动光盘或U盘,插入到要备份的CentOS 6.0 Linux上面,设置好开机启动(我这里用的是U盘,所以 ...