Window.SourceInitialized事件何时引发 [英] When is the Window.SourceInitialized event raised
问题描述
我可以保证在Window.Loaded
事件之前总是引发Window.SourceInitialized
事件吗?
我需要HwndSource
对象在我的 Window.Loaded事件处理程序中进行进一步处理,但是我不确定到那时是否总是可用
Can I guarantee the Window.SourceInitialized
event will always be raised before the Window.Loaded
event?
I need the HwndSource
object for further processing in my Window.Loaded event handler and I'm not sure if this will always be available by then
推荐答案
以下是您可以预期的事件序列(应该在加载之前发生):
Here's the sequence of events you can expect (it should occur before Loaded):
如果您要仔细检查,或者不信任获取SourceInitialized事件...那么您可以尝试自己获取HwndSource ...以查看其是否已连接.
If you want to double-check, or don't trust getting the SourceInitialized event...then you can try and obtain the HwndSource yourself....to see if it's connected.
这篇关于Window.SourceInitialized事件何时引发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!