我们如何将消息框行为分配给WPF中的任何窗口 [英] How can we assign the messagebox behaviour to any window in WPF

查看:57
本文介绍了我们如何将消息框行为分配给WPF中的任何窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有

我要求我需要在新窗口中显示消息而不是消息box.show()。



,在这里我使用了最顶层的属性,它显示了顶部,但是如果单击表单,则允许不关闭该表单。



我尝试过:



这是我使用的另一种形式,如

if(cmd.ExecuteNonQuery()> 0)

{

AlertMessage alt =新的AlertMessage(成功更新);

alt.Topmost = true;

alt。显示();

}



这是警报消息窗口构造函数:

public AlertMessage(string s)

{

InitializeComponent();

this.lblmessage.Content = s.ToString();

}

我通过构造函数将消息传递给这个窗口。

如何阻止用户执行orm任何没有关闭的行动请帮帮我..

hi all
I have the requirement that I need to display the messages in a new window instead of message box.show().

and here I used topmost property it's showing top but if click on out of form it's allowing without closing that form.

What I have tried:

this is another form where i used like
if (cmd.ExecuteNonQuery() > 0)
{
AlertMessage alt = new AlertMessage("Updated Successfully");
alt.Topmost = true;
alt.Show();
}

this is alert message window constructor:
public AlertMessage(string s)
{
InitializeComponent();
this.lblmessage.Content = s.ToString();
}
I am passing message to this window through the constructor.
how to stop the user to perform any action without closing this please help me..

推荐答案

使用 .ShowDialog()方法打开窗口作为模态对话框。

Use the .ShowDialog() method to open the window as a modal dialog.
AlertMessage alt = new AlertMessage("Updated Successfully");
//alt.Topmost = true; // probably not necessary if being shown as modal
alt.ShowDialog();


这篇关于我们如何将消息框行为分配给WPF中的任何窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆