确定从哪个视图/用户控件调用命令
是否有任何明确的方法来确定从哪个视图(用户控件)调用命令?
例如,如果我有两个视图,每个视图都绑定到同一个 ViewModel,那么我如何确定从哪个视图调用特定命令?在这种情况下,为每个视图使用单独的命令不会产生任何影响,因为它是一个外部服务,应该通知特定的活动视图。
Is there any definitive way of determining from which View (UserControl) a command was called?
For instance, if I have two Views, each tied to the same ViewModel, how might I determine from which View a particular command was called? Having a separate command for each View would not make a difference in this scenario, as it is an external service which ought to be notified of the particular active View.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您从用户控件调用该命令。因此,如果您调用方法 someMethod,则要求该方法将 UserControl 对象作为参数。换句话说,你应该有类似的东西:
并在你的用户 conrtoll 上调用该方法:
I am assuming that you call the command from a usercontrol. So if you call the method someMethod for example then require that method to take a UserControl object as a parameter. In other words you should have somethin like:
And on your user conrtoll call that method as: