如何知道何时在WPF中渲染(绘制)控件(或窗口)? [英] How to know when a control (or window) has been rendered (drawn) in WPF?

查看:403
本文介绍了如何知道何时在WPF中渲染(绘制)控件(或窗口)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将Window的内容存储到图像中,将其保存并关闭窗口。如果在已加载事件中关闭窗口,则该图像包含窗口,其中某些项目被绘制为 OK,另一些项目仅被绘制或扭曲了一半,而其他项目不在图像上。



如果我放置一个计时器并在一定时间后关闭窗口(取决于窗口的复杂度,介于250ms到1sec之间),图像就可以了。



看起来窗口需要一些时间才能完全呈现自己。



谢谢。



谢谢。



谢谢。

解决方案

我认为您正在寻找 ContentRendered 事件


I need to store the content of a Window into an image, save it and close the window. If I close the window on the Loaded event the image contains the Window with some items are drawn ok, some others are only half drawn or distorted while others are not on the image.

If I put a timer and close the window after a certain amount of time (something between 250ms and 1sec depending on the complexity of the window) the images are all ok.

Looks like the window needs some time to completely render itself. Is there a way to know when this rendering has been done to avoid using a Timer and closing the window when we know it has completed its rendering?

Thanks.

解决方案

I think you are looking for the ContentRendered event

这篇关于如何知道何时在WPF中渲染(绘制)控件(或窗口)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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