首页 聚焦 财经 产业 证券 股市 商业 民生 IPO 点评 IPhone客户端 安卓客户端
首页/经济论坛

1

Dialogresult表示窗口关闭后返回一个窗口的结果
2021-05-17

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;

声明:登载此文出于传递信息之目的,本站仅供信息保存,如有异议请联系我们修订!
点赞
编辑:中证
中证新闻网
中证新闻网
中证点评更多

    近日,上市近半年的极兔速递(015...[详细]

    新一轮产业革命和科技变革为我国...[详细]

民生经济更多
中证新闻网
科创板块更多
热搜汇聚更多
  • 合作: 商洽与内容纠错联系方式
  • Email:894204689@qq.com
  • CopyRight@2008-2024 中国证券新闻 All Right Reserved

    工信备案号:备案号京ICP(备)15095275

    中国证券新闻版权所有违者必究