WPF弹出窗口 [英] WPF popup window
问题描述
我想,让用户选择自己的选项单击一个按钮后。例如,显示两个按钮,立即重新启动,并在一个模式弹出窗口稍后重新启动将是我的偏好。使用的MessageBox
不是我一个解决方案,因为它不允许用户更改按钮的标题。
I would like to let the user choose their options after a button is clicked. For example, showing two buttons, "Restart Now" and "Restart Later" in a modal popup window would be my preference. Using a MessageBox
is not a solution for me as it does not allow the user to change the title of buttons.
推荐答案
您需要创建一个新的窗口类。你可以设计一个,那么你想要的任何方式。您可以创建和模态显示一个窗口,像这样的:
You need to create a new Window class. You can design that then any way you want. You can create and show a window modally like this:
MyWindow popup = new MyWindow();
popup.ShowDialog();
您可以添加自定义属性的结果值,或者如果你只有两种可能的结果(+可能undeterminate,这将是空
),您可以设置窗口的 的DialogResult
财产关闭它,然后检查它(这是由归国前值的ShowDialog ()
)。
You can add a custom property for your result value, or if you only have two possible results ( + possibly undeterminate, which would be null
), you can set the window's DialogResult
property before closing it and then check for it (it is the value returned by ShowDialog()
).
这篇关于WPF弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!