Silverlight 2 中缺少 Unload 事件
Silverlight 2 缺少 UserControl 的卸载事件。有人为此实施了解决方法吗?
Silverlight 2 is missing the unload event for a UserControl. Has anyone implemented a workaround for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可能想看看这里:
http://gallery.expression.microsoft.com/en-us/SLUnloadedBehavior
该代码适用于 SL 3,但如果删除行为代码,它应该适用于 Sl2
@KeithMahony
一种情况是您想要防止事件内存泄漏,这是大多数人倾向于忽略的 silverlight 开发的陷阱之一。
you might want to look here:
http://gallery.expression.microsoft.com/en-us/SLUnloadedBehavior
The code is for SL 3 but if you remove the behavior code it should work for Sl2
@KeithMahony
One scenario is that you want to prevent event memory leaks, one of the pitfalls of silverlight development that most people tend to ignore.
我认为您会得到的最接近的是应用程序服务,它可以让您检测Silverlight何时应用程序正在关闭并对其做出响应。如果您使用的是导航应用程序,那么您可以挂钩父框架的导航事件来确定页面正在“卸载”。
您想要做什么需要 UserControl 响应卸载事件?
I think the closest you'll get is Application Services which let you detect when the Silverlight application is closing and respond to it. If you're using a Navigation application then you can hook into the Navigating event of the parent frame to determine that the page is "unloading".
What are you trying to do that requires a UserControl to respond to an unloading event?
考虑使用 Silverlight 4。我最后附带了一个 已卸载事件。
Consider using Silverlight 4. I comes with - at last - an Unloaded event.