条件键绑定
我在想是否有人可以向我解释如何进行条件键绑定(使用 MVVM 模式),目前我已经做到了,
<Window.InputBindings>
<KeyBinding Command="{Binding Path=CMD_Login}" Gesture="Enter" />
</Window.InputBindings>
但我希望此键绑定仅在用户登录时才处于活动状态。他们登录窗口设置为可见/折叠,具体取决于用户是否登录,因此是否可以基于该条件进行徘徊?
谢谢
I was wandering if someone could explain to me how I could do a conditional key binding (using an MVVM pattern), at the moment I have
<Window.InputBindings>
<KeyBinding Command="{Binding Path=CMD_Login}" Gesture="Enter" />
</Window.InputBindings>
but I would like this key-binding to only be active if the user is logging in. They login window is set to visible/collapse depending if the user is logging in or not, so was wandering if the conditional can possibly be based on that?
Thank You
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您有一个命令,
CanExecute
部分不应该通过不总是返回 true 来处理该命令吗?If you have a command, shouldn't the
CanExecute
part handle that by not always returning true?