WPF 用ShowDialog的方法显示窗口的返回值

来源:互联网 发布:easypangel mysql目录 编辑:程序博客网 时间:2024/06/05 02:17

using System;using System.Windows;using System.Windows.Controls;namespace CSharp{    public partial class DialogBox : Window    {        public DialogBox()        {            InitializeComponent();        }        // The accept button is a button whose IsDefault property is set to true.        // This event is raised whenever this button is clicked, or the ENTER key        // is pressed.        void acceptButton_Click(object sender, RoutedEventArgs e)        {            // Accept the dialog and return the dialog result            this.DialogResult = true;        }    }}


只要设置了DialogResult属性(true或false),窗口就会退出,ShowDialog()的返回值就是DialogResult,然后通过判断DialogResult是true还是false来确定用户意愿。

0 0
原创粉丝点击