[源码下载]

背水一战 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(文本输入框,下拉选择框)的更多相关文章

  1. 背水一战 Windows 10 (107) - 通知(Toast): 提示音, 特定场景

    [源码下载] 背水一战 Windows 10 (107) - 通知(Toast): 提示音, 特定场景 作者:webabcd 介绍背水一战 Windows 10 之 通知(Toast) 提示音 特定场 ...

  2. 背水一战 Windows 10 (106) - 通知(Toast): 通过 toast 打开协议, 通过 toast 选择在指定的时间之后延迟提醒或者取消延迟提醒

    [源码下载] 背水一战 Windows 10 (106) - 通知(Toast): 通过 toast 打开协议, 通过 toast 选择在指定的时间之后延迟提醒或者取消延迟提醒 作者:webabcd ...

  3. 背水一战 Windows 10 (104) - 通知(Toast): 纯文本 toast, 短时 toast, 长时 toast, 图文 toast

    [源码下载] 背水一战 Windows 10 (104) - 通知(Toast): 纯文本 toast, 短时 toast, 长时 toast, 图文 toast 作者:webabcd 介绍背水一战 ...

  4. 背水一战 Windows 10 (103) - 通知(Toast): 基础, 按计划显示 toast 通知

    [源码下载] 背水一战 Windows 10 (103) - 通知(Toast): 基础, 按计划显示 toast 通知 作者:webabcd 介绍背水一战 Windows 10 之 通知(Toast ...

  5. 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButton, AppBarButton, AppBarToggleButton

    [源码下载] 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButt ...

  6. 背水一战 Windows 10 (111) - 通知(Tile): secondary tile 模板之图片, secondary tile 模板之分组

    [源码下载] 背水一战 Windows 10 (111) - 通知(Tile): secondary tile 模板之图片, secondary tile 模板之分组 作者:webabcd 介绍背水一 ...

  7. 背水一战 Windows 10 (112) - 通知(Badge): application 的 badge 通知, secondary 的 badge 通知, 轮询服务端以更新 badge 通知

    [源码下载] 背水一战 Windows 10 (112) - 通知(Badge): application 的 badge 通知, secondary 的 badge 通知, 轮询服务端以更新 bad ...

  8. 背水一战 Windows 10 (110) - 通知(Tile): secondary tile 模板之基础, secondary tile 模板之文本

    [源码下载] 背水一战 Windows 10 (110) - 通知(Tile): secondary tile 模板之基础, secondary tile 模板之文本 作者:webabcd 介绍背水一 ...

  9. 背水一战 Windows 10 (109) - 通知(Tile): 按计划显示 tile 通知, 轮询服务端以更新 tile 通知

    [源码下载] 背水一战 Windows 10 (109) - 通知(Tile): 按计划显示 tile 通知, 轮询服务端以更新 tile 通知 作者:webabcd 介绍背水一战 Windows 1 ...

随机推荐

  1. Winform导入文件

    winfrom的选中文件的路径放进文本框,我还是一个新手,欢迎大家在评论里面多多指教

  2. LinkedIn TAG

                 List1  [leetcode]243. Shortest Word Distance最短单词距离 Two Pointers [leetcode]244. Shortest ...

  3. vue中具名插槽的使用

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. scrapy Mongodb 储存

    pipelines.py # -*- coding: utf-8 -*- # Define your item pipelines here # # Don't forget to add your ...

  5. boost多线程入门介绍

    :first-child { margin-top: 0px; } .markdown-preview:not([data-use-github-style]) h1, .markdown-previ ...

  6. 一个不错的多叉树, stl风格

    tree<std::string> tr9; tree<std::string>::pre_order_iterator iter1; tr9.set_head("h ...

  7. dskinlite(uieasy mfc界面库)使用记录3:绘制动态元素(按钮控件通过隐藏方式修改图片显示)

    效果图: 分别是:正常,正常鼠标悬停,按下,按下鼠标悬停 XML代码: 75,76行定义了一个image,注意id和index属性 初始化代码: click代码: 147,148,153,154:通过 ...

  8. Matting任务里的Gradient与Connectivity指标

    Matting任务里的Gradient与Connectivity指标 主要背景 Matting任务就是把α(不透明度, 也就是像素属于前景的概率).F(前景色)和B(背景色)三个变量给解出来. C为图 ...

  9. CPDA-战略管理

    战略管理-PEST分析-市场分析-竞争环境分析-SWOT分析-内/外部因素评价矩阵-国际化/多元化战略 战略管理: 战略分析->战略制定->战略实施->战略评价->战略分析,四 ...

  10. pip install cv2报错

    pip install cv2 安装cv2报错: Could not find a version that satisfies the requirement cv2 (from versions: ...