如何让 MessageBox.Show() 在我的 WPF 应用程序中间弹出? [英] How to get MessageBox.Show() to pop up in the middle of my WPF application?

查看:67
本文介绍了如何让 MessageBox.Show() 在我的 WPF 应用程序中间弹出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 700w x 300h WPF 应用程序,可以将它拖动到大屏幕上的任何位置.

I have a 700w x 300h WPF applciation and can drag it anywhere on my large screen.

当我的应用程序执行时:

When my application executes:

MessageBox.Show("Sorry, this function is not yet implemented.");

消息框出现在我的屏幕中间,它可能靠近也可能不靠近应用程序本身.

the mesage box appears in the middle of my screen, which may or may not even be near the application itself.

如何让我的 MessageBox 出现在我的应用程序中间?

How can I get my MessageBox to appear in the middle of my application instead?

推荐答案

如果您的应用有多个窗口,您可能需要使用 Application.Current.MainWindow:

If your app has several windows, you might want to use Application.Current.MainWindow:

MessageBox.Show(Application.Current.MainWindow, "Can't login with given names.", "Login Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);

这篇关于如何让 MessageBox.Show() 在我的 WPF 应用程序中间弹出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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