//利用委托传递成员函数
eg:
<Button Command="{Binding ShowCommand}" />
绑定了类里面的某个成员
//在.xaml.cs中实例化
this.DataContext = new MainViewModel();
//创建新的类库
public class MainViewModel { public MainViewModel() { ShowCommand = new MyCommand(Show); } public MyCommand ShowCommand { get; set; } public void Show() { MessageBox.Show("点击按钮"); } }
//
标签:MyCommand,Show,ShowCommand,命令,MainViewModel,new,public From: https://www.cnblogs.com/PIPTWY/p/17388039.html