【发布时间】:2015-04-06 06:13:46
【问题描述】:
我目前正在使用 Caliburn.Micro 处理 WPF 项目,并希望将 KeyDown 事件绑定到 UserControl。如果Window 被打开并且用户按下任何按钮,它应该被触发。
<UserControl x:Class="Test.Views.AppView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cal="http://www.caliburnproject.org"
cal:Message.Attach="[Event KeyDown] = [TestMethod($executionContext)]" />
很遗憾,这段代码不起作用。是否可以将Event 绑定到UserControl,而不是绑定到TextBox 或Button 等特定控件?
【问题讨论】:
-
看看这个链接对你有没有帮助 - stackoverflow.com/questions/16719496/…
标签: c# wpf mvvm caliburn.micro