首页 头条 财经 产业 跨境 时尚 物流 直播 零售 WAP端
首页 / 数字经济 / 正文

Dialogresult表示窗口关闭后返回一个窗口的结果

来源:
编辑:电经淘讯
时间:2023-08-27

VS里DialogResult 表示窗口关闭后返回一个窗口的结果。在程序中一旦设置DialogResult的值,接下来就会自动执行close()的方法,所以没有必要写this.close(),并且也没有必要设定closing和closed事件,其执行顺序为DialogResult=true/false->closing事件->closed事件而在调用对话框的主程序中建议如下写法:


           Win_Filter win = new Win_Filter();
            win.ShowDialog();
            result = (bool)win.DialogResult;
            if (result==false)
            {
                Shared_Data.Sub_Info_VM.bDel_Open = bDel_Open;
                Shared_Data.Sub_Info_VM.bDel_Limit = bDel_Limit;
            }
//dialog
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace JPT_Tester
{
      /// <summary>
      /// Interaction logic for Win_Filter.xaml
      /// </summary>
      public partial class Win_Filter : Window
      {
          public Win_Filter()
          {
            InitializeComponent();
            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
          }
          private void Button_Click_1(object sender, RoutedEventArgs e)
          {
              this.DialogResult = true;
          }
          private void Window_Loaded_1(object sender, RoutedEventArgs e)
          {
              this.DataContext = Shared_Data.Sub_Info_VM;

头条聚焦更多
经济视界更多

安踏的“钞能力”,中产的收割机

    前不久,安踏发布2023年财报:2023年,安...[详细]

曹操出行港交所递表:依赖聚合平台 盈

     网约车领域又将诞生一个新的IPO。4...[详细]

热点财经更多
  • CopyRight @ 2013-2024 Reserved CN电商经济网版权所有所涉内容免责声明查阅