如何判断UserControl已经加载完毕?
如何判断UserControl已经加载完毕?
我有一些用户控件,其中包含来自另一台服务器的图像和媒体文件,如下所示:
<Image Source="{Binding Image}" />
我想知道我的所有图像何时下载并准备好显示。 我注意到一个事件 ImageLoaded,并且可能我可以在所有图像控件上监听它。难道没有更好的方法吗?
How to determine that UserControl has been loaded completely?
I have some UserControls with images and media files from another server bound like that:
<Image Source="{Binding Image}" />
I would like to know when all my images are downloaded and ready to be shown.
I've noticed an event ImageLoaded, and probably I can listen to it on all of my Image controls. Isn't there a better way to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
FrameworkElement 类包含一个名为“Loaded”的公共事件,因此从它派生的所有类(UserControl 类)自然也会公开它。
MSDN
问题会是:您正在下载图像吗? (这可以在加载控件检查此处之后进行)或者您是否将图像嵌入到项目?它们将成为您启动应用程序时下载的 .xap 文件的一部分。
您可以向该事件添加事件处理程序,以便在该事件发生时执行代码。希望有帮助。
The class FrameworkElement contains a public event called "Loaded", so naturally all classes derviving from it (UserControl class) expose it as well.
MSDN
The question would be : Are you downloading your images ? (This can be after loading of the control Check here) Or are you embedding your images in the project? They'll be a part of the .xap file that's downloaded when you launch your application.
You can add an event handler to that event to execute code when the said event occurrs. Hope that helps.