我如何确定一个WPF窗口模式? [英] How do I determine if a WPF window is modal?
问题描述
什么是找出最简单的方法,如果一个窗口模态还是不开?
What's the easiest way to figure out if a window is opened modally or not?
CLARIFIACTION: 我打开一个窗口,调用
CLARIFIACTION: I open a window calling
myWindow.ShowDialog();
我有一个OK和放一个页脚; 取消按钮,我只希望如果窗口打开模态展现。现在我知道我可以这样设置属性:
I have a footer with an "OK" & "Cancel" button that I only want to show if the window is opened modally. Now I realize I can set a property by doing this:
myWindow.IsModal = true;
myWindow.ShowDialog();
不过,我想这是自作出这样的决定的窗口。我要检查在该窗口的装事件是否是模式的。
But I want the window it's self to make that determination. I want to check in the "Loaded" event of the window whether or not it is modal.
更新 而IsModal属性没有的实际上的存在于一个WPF窗口。这是我创建了一个属性。的ShowDialog()块中的当前线程。我猜我可以确定窗口是由若当前线程被阻塞检查通过的ShowDialog()打开。我怎么会去这样做?
UPDATE The "IsModal" property doesn't actually exist in a WPF window. It's a property that I have created. ShowDialog() blocks the current thread. I'm guessing I can determine if the Window is opened via ShowDialog() by checking if the current thread is blocked. How would I go about doing that?
推荐答案
从<一个href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c95f1acb-5dee-4670-b779-b07b06afafff/">http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c95f1acb-5dee-4670-b779-b07b06afafff/
System.Windows.Interop.ComponentDispatcher.IsThreadModal可以告诉你,如果调用线程当前正在运行的模式HWND。的
这篇关于我如何确定一个WPF窗口模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!