【问题标题】:Disable background until form disappears [duplicate]禁用背景直到表单消失[重复]
【发布时间】:2017-06-20 03:56:28
【问题描述】:

我想禁用我的应用程序的背景窗口,直到顶部窗口关闭。就像错误消息窗口一样。

【问题讨论】:

    标签: c# wpf


    【解决方案1】:

    您可以通过 ShowDialog 做到这一点:

    public void ShowMyDialogBox()
    {
       using(var testDialog = new Form2())
       {
          // Show testDialog as a modal dialog and determine if DialogResult = OK.
          if (testDialog.ShowDialog(this) == DialogResult.OK)
          {
             // Read the contents of testDialog's TextBox.
             this.txtResult.Text = testDialog.TextBox1.Text;
          }
          else
          {
             this.txtResult.Text = "Cancelled";
          }
       }
    }
    

    Source

    【讨论】:

      【解决方案2】:

      当您显示新窗口时,您需要使用 ShowDialog 函数 - 而不仅仅是 Show 函数:

      Window dialogWindow = new Window()
      dialogWindow.ShowDialog()
      

      【讨论】:

        猜你喜欢
        • 2014-06-26
        • 1970-01-01
        • 2020-07-20
        • 2020-07-27
        • 1970-01-01
        • 2021-12-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多