WPF窗体的命令绑定
2014-02-09 16:34
183 查看
方法一:使用代码
构造函数
上面等同于如下代码:
<WpfUI:View.CommandBindings> <CommandBinding Command="Help" CanExecute="HelpCanExecute" Executed="HelpExecuted" /> </WpfUI:View.CommandBindings>
#region Command private void HelpCanExecute(object sender, CanExecuteRoutedEventArgs e) { e.CanExecute = true; } private void HelpExecuted(object sender, ExecutedRoutedEventArgs e) { System.Diagnostics.Process.Start("http://www.baidu.com"); } #endregion Command
构造函数
public TallyBookView() { InitializeComponent(); this.InputBindings.Add( new KeyBinding(ApplicationCommands.Help, new KeyGesture(Key.F2))); }
上面等同于如下代码:
<WpfUI:View.InputBindings> <KeyBinding Command="Help" Key="F2" /> <KeyBinding Command="NotACommand" Key="F1"/> </WpfUI:View.InputBindings>
相关文章推荐
- WPF中的EventTrigger和命令绑定
- WPF命令,自定义命令,相对绑定,代码设置绑定,绑定参数
- 微软WPF技术应用与实践系列(窗体与导航+容器+模型+数据绑定配多个应用案例)
- WPF中命令的绑定
- WPF 通过行为将事件绑定到命令
- WPF Prism框架下基于MVVM模式的命令、绑定、事件
- WPF 给控件添加可以绑定的命令
- WPF中的EventTrigger和命令绑定
- 将命令绑定到事件中(WPF)
- WPF 在事件中绑定命令
- [WPF]MVVM模式下如何在后台cs中调用绑定命令
- WPF学习系列032: 3.4.3 带有内建命令绑定的控件
- WPF窗体视图中绑定Resources文件中字符串时,抛出:System.Windows.Markup.StaticExtension
- WPF 在事件中绑定命令(不可以在模版中绑定命令)
- WPF命令(Command)介绍、命令和数据绑定集成应用
- 关于wpf的命令绑定command的指向控件绑定问题,Path=和ElementName=设定
- WPF中的EventTrigger和命令绑定
- 【2016-11-15】【坚持学习】【Day26】【WPF 命令绑定到事件】
- WPF中的命令与命令绑定(二)
- WPF中的命令与命令绑定——出自《IT168》