当前位置:网站首页>win10 uwp ContentDialog 点确定不关闭
win10 uwp ContentDialog 点确定不关闭
2022-08-07 14:49:00 【林德熙】
微软的ContentDialog不是一直有,而是UWP新的,可以使用Content放用户控件,使用很好,但是一点不好的是,默认的一点击下面按钮就会退出。
我们有时候需要ContentDialog用户输入,而用户没有输入我们想要的,给用户提示,不退出
那么要解决ContentDialog自动退出有两个方法:
第一个很简单,第二个更简单
简单的方法,做一个类继承ContentDialog,然后加一个属性
/// <summary>
/// 对话完成,如果没有完成会继续显示
/// </summary>
public bool Complete
{
set;
get;
}在Closing判断他是不是为false,如果是,那么取消,取消在e那里
这个简单,就不放代码。
第二个方法,为什么我们要使用自带的按钮?其实可以在我们的控件自己写按钮
那么有新的问题,自己写按钮,那么怎么退出,其实我们可以使用ContentDialog的Hide()方法,这个方法可以让ContentDialog退出,是默认关闭。
我做到这发现,自己做的控件按钮实在有点麻烦,不如用一个简单的方法,我们在我们控件加个属性
/// <summary>
/// 对话完成,如果没有完成会继续显示
/// </summary>
public bool Complete
{
set;
get;
}当然在PrimaryButtonClick,如果输入和我们要的一样,Complete = true; SecondaryButtonClick就不需要判断Complete = true;
在最后
while (!控件.Complete)
{
await contentDialog.ShowAsync();
}边栏推荐
猜你喜欢

C专家编程 第8章 为什么程序员无法分清万圣节和圣诞节 8.5 原型在什么地方会失败

【数据库系统原理】第三章 BC范式、第三范式和第四范式

嵌入式开发:嵌入式基础–了解微控制器引导过程

C Expert Programming Chapter 7 Thinking About Memory 7.8 Take it easy --- "Thing King" and "Page Game"

LeetCode hot topic HOT 100 (10. Delete the Nth node from the bottom of the linked list)

联盛德W801系列1-flash保存数据例程:保存wifi配网信息

001_微服务框架学习分类总结

C专家编程 第8章 为什么程序员无法分清万圣节和圣诞节 8.7 用C语言实现有限状态机

初始百度地图API
![[Principle of Database System] Chapter 4 Advanced Database Model: E/R Model and Its Design Rules and Constraints](/img/67/c6ee5068487bb812c8092fce7ad81c.png)
[Principle of Database System] Chapter 4 Advanced Database Model: E/R Model and Its Design Rules and Constraints
随机推荐
线程的控制与同步
[Principle of Database System] Chapter 3 BC Normal Form, Third Normal Form and Fourth Normal Form
Threads of control and synchronization
dotnet 线程静态字段
Postgresql logical backup tool pg_dump and pg_resotre learning
基于TCP的聊天系统
我,一个软件测试工程师,谈谈我每天的日常工作...
Flink CDC
AQS同步组件-Semaphore(信号量)解析和案例
dotnet 特性 DynamicallyInvokable 是用来做什么的
【C语言】操作符详解
Hash table | The sum of three numbers, the sum of four numbers | The most suitable `double pointer method` | leecode brush notes
03 【常用类型(下)】
05 【Interface interface VS type】
云信小课堂 | 基于 NERoom 快速实现在线会议
LeetCode hot topic HOT 100 (4. Find the median of two positive-order arrays)
LeetCode 热题 HOT 100(8.三数之和)
LeetCode 热题 HOT 100(5.最长回文子串)
Research on the relationship between Yun and Enmo on "HTAP" and "Intelligent Warehouse Lake"
2022牛客多校六 A-Array(构造+哈夫曼)