检测从Application.Current.RootVisual Silverlight ChildWindow打开
我如何从 Silverlight 主 UserControl (RootVisual) 知道 ChildWindow 正在显示?
How can I know from my Silverlight main UserControl (RootVisual) that a ChildWindow is displaying?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定是否有比自己设置接线更具体的方法。
1) 您需要创建一个公共单例类(即 ChildWindowManager),其中包含名为 OnChildWindowShowing 的事件。然后,您的根视觉对象将订阅该事件。
2) 为了使该事件在适当的时间触发,您需要在 ChildWindow 实例上设置一些连接。您可以根据具体情况执行此操作,也可以创建一个继承自 ChildWindow 并具有自定义构造函数的类。但是您需要在 ChildWindow 上设置事件,这将导致我们之前创建的单例类上的 OnChildWindowShowing 事件触发。
所以从概念上来说它看起来像:
ChildWindow.OnShow() <--> ChildWindowManager.OnChildWindowShowing <-->;根视觉
Not sure if there's any way more specific than setting up the wiring yourself.
1) You would want to make a public singleton class (ie. ChildWindowManager) that contains an event called OnChildWindowShowing. Your root visual would then subscribe to that event.
2) In order to make that event fire at proper times, you need to set up some wiring on your ChildWindow instances. You can do this on a case by case basis, or you can make a class that inherits from ChildWindow and has custom constructor. But you need to set events on the ChildWindow that would cause OnChildWindowShowing event on the singleton class we created before to fire.
So conceptually it would look something like:
ChildWindow.OnShow() <--> ChildWindowManager.OnChildWindowShowing <--> RootVisual