背水一战 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 ...
随机推荐
- python字符串之format格式化函数
学习中~ 觉得应该系统地学习一下python,今天学习了字符串,以下是自己的笔记. 首先说一下format函数,用{}和:代替了%,比如: >>>“{} {} {}”.format( ...
- MySQL增删改查常用语句命令
增删改查语句增删改查的语句命令为 增:insert删:delete改:update查:SELECT或者show 库操作创建数据库:create database shujukuba;创建带字符集的数据 ...
- H3 BPM J.V10.6.1 安装及快速使用手册
直接进入地址下载:http://bbs.h3bpm.com/read.php?tid=3103&fid=30,需要注册. 按照文档"H3 BPM J.V10.6.1 安装及快速使用手 ...
- Centos 系统swap虚拟内存添加与删除配置
SWAP是Linux中的虚拟内存,用于扩充物理内存不足而用来存储临时数据存在的.它类似于Windows中的虚拟内存.在Windows中,只可以使用文件来当作虚拟内存.而linux可以文件或者分区来当作 ...
- 在MyEclipse中使用spring-boot+mybatis+freemarker实现基本的增删改查
一.基本环境 二.创建实体类 1.User.java package bjredcross.rainbowplans.model; import bjredcross.rainbowplans.com ...
- Android自动化之Monkey测试(二)
本文主要从以下方面进行分享. 一.查看应用包名二.Monkey启动三.Monkey停止四.Monkey命令五.日志分析 一.查看应用包名 大多数时候,我们都是对特定的应用进行monkey测试,因此需要 ...
- selenium+java定位163/126邮箱元素显示定位失败解决
开始在没有进入iframe时,用任何方法定位163/126邮箱登录页面的元素都不可能定位到,eclipse工作台会显示Unable to locate element:…… 这种情况我遇到了两种原因: ...
- 三、PyQt5不同方法创建菜单栏、工具栏和状态栏
创建菜单栏.工具栏和状态栏可以直接通过代码实现,也可以通过Qt Designer中的属性编辑器等实现.通过两种方法的学习可以加深理解,更好的掌握PyQt5. 一.菜单栏与状态栏 状态栏的设置比较简单, ...
- 使用Python完成排序(快排法、归并法)
class Sort(object): def quick_sort(self, ls): self.quick_sort_helper(ls, 0, len(ls) - 1) return ls d ...
- pl/sql调试存储过程
1.找到对应的存储过程 2.在存储过程名称上右键,选择Test 3.点击1标识的按钮(begin debugger),选择2开始调试 4.存储过程如需参数,需要在右侧下方的表格区域(3)填入对应的值即 ...