简体   繁体   English

Window.Show()-如何保证窗口在屏幕上

[英]Window.Show() - How can I guarantee that window is on screen

I have a WPF application rendering WPF content inside a Window. 我有一个WPF应用程序,可在Window内呈现WPF内容。 We call Window.Show() to put the content on screen. 我们调用Window.Show()将内容显示在屏幕上。

We use a StopWatch to measure elasped time with Start/Stop calls either side of the Show() call, and log out every time the Show is called. 我们使用StopWatch在Show()调用的任一侧通过Start / Stop调用来测量耗时,并在每次调用Show时注销。

When I have my elapsed time, is this enough to guarantee that the Window is on screen, or is the GPU still putting the WPF content on the screen even though the Show call is complete? 经过时间后,这是否足以确保Window在屏幕上,或者即使Show调用已完成,GPU仍将WPF内容显示在屏幕上吗? Is the ContentRendered a better event to listen to, or could this also complete before the content is on screen? 是将ContentRendered作为更好的事件来听,还是可以在内容显示之前完成?

Is anyone aware of any alternative methods of measuring when WPF content is truly on the user's screen? 有人知道WPF内容何时真正出现在用户屏幕上的任何替代方法吗?

Use Window.Loaded event handler, as it is explained in the MSDN Loaded event : 使用Window.Loaded事件处理程序,如MSDN Loaded事件中所述:

Occurs when the element is laid out, rendered, and ready for interaction. 在元素被布置,渲染并准备好进行交互时发生。

And I think it's just what you need. 我认为这正是您所需要的。 More about it you can find here MSDN 有关它的更多信息,请参见MSDN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM