多个按键绑定到单个命令

发布于 2024-08-29 06:13:42 字数 139 浏览 1 评论 0原文

我的窗口只有一个列表视图。这方便用户增量搜索数据库。由于设计没有文本框,因此我必须全局处理按键。我认为这可以通过按键绑定来实现。但是我如何处理所有键并将其关联到单个命令。

如果有的话还建议我其他方法。

PS:我想要这个在xaml中

My window has just a listview. This facilitates the users to incremental search the db. Since the design does not have a textbox, i've to globally handle the keys. I think it could be achieved by keybinding. But how can i handle all the keys and associate it to a single command.

Also suggest me other methods if any.

P.S.: I want this in xaml

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

汹涌人海 2024-09-05 06:13:42

我将使用 EventToCommand 将 KeyDown 事件绑定到 ViewModel 上的命令。您可以将 PassEventArgsToCommand 设置为 true,并使用 RelayCommand 来找出按下的键。

所有这些对象都可以在 MVVM Light Toolkit

http://www.galasoft.ch/mvvm/getstarted< /a>

干杯,
洛朗

I would use an EventToCommand binding the KeyDown event to a command on the ViewModel. You can set PassEventArgsToCommand to true, and use a RelayCommand to find out what key as pressed.

All these objects are available in the MVVM Light Toolkit

http://www.galasoft.ch/mvvm/getstarted

Cheers,
Laurent

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文