<Window x:Class="WpfTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfTest"
mc:Ignorable="d"
Title="MainWindow" Height="" Width="">
<Grid>
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="190,140,0,0" VerticalAlignment="Top" Width="" Height=""
Command="{Binding ButtonCom}" CommandParameter="测试数据绑定"/>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes; namespace WpfTest
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.DataContext = this;
} private ICommand _buttonCom = new ButtonCommand(); public ICommand ButtonCom
{
get
{
return _buttonCom;
} set
{
_buttonCom = value;
}
}
} public class ButtonCommand : ICommand
{
public event EventHandler CanExecuteChanged; public bool CanExecute(object parameter)
{
return true;
} public void Execute(object parameter)
{
MessageBox.Show(parameter.ToString());
}
} }

CommandParameter就是传递的parameter

最新文章

  1. Eclipse JAVA文件注释乱码
  2. iOS 学习 - 10下载(1) NSURLConnection 篇
  3. CodeForces 173E Camping Groups 离线线段树 树状数组
  4. iOS7 人机界面设计指南
  5. 第九篇:web之前端之web上传文件的方式
  6. JS,JQuery杂谈
  7. 使用swagger实现web api在线接口文档
  8. python GUI实战项目——tkinter库的简单实例
  9. (转)Java开发中的23种设计模式详解
  10. Vue源码后记-钩子函数
  11. 用java代码发送http请求
  12. Mac下安装Homebrew并升级subversion
  13. Java面向对象进阶篇(内部类)
  14. weblogic补丁下载与安装补丁的方法
  15. ORA-00600: internal error code, arguments: [2662]
  16. vue-update-表单形式复写方法上传图片
  17. 【慕课网实战】Spark Streaming实时流处理项目实战笔记二十一之铭文升级版
  18. 页面中 js,css 集中提取
  19. javaScript高级教程(七)正则表达式中括号三种常见作用
  20. selenium3启动浏览器

热门文章

  1. hbase shell 常用命令
  2. nyoj 170 网络的可靠性
  3. {dockerUI}在服务器上直接安装shipyard/shipyard
  4. Hive Word count
  5. jquery中的each()方法详解
  6. CSS 实用技巧:制作三角形
  7. Spring 一二事(5) - 依赖注入
  8. scp: command not found如何解决
  9. SpringMVC常用接收Json的两种方法
  10. H5 canvas绘制出现模糊的问题