简体   繁体   English

条件键绑定

[英]Conditional Keybinding


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 我正在徘徊,如果有人可以向我解释我该如何做条件键绑定(使用MVVM模式),

 <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 谢谢

如果您有命令,那么CanExecute部分不应该通过不总是返回true来处理该命令吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM