https://blog.csdn.net/weixin_30896511/article/details/98689635
本文只谈在后台xaml.cs中的绑定,不讨论前台xaml中的绑定。代码为片段式,表意即可
按照命令的声明及在后台cs中的调用,直接上代码了。
1. VM中声明
#region 绑定通知
/// <summary>
/// 点击密码重置时的通知
/// </summary>
public RelayCommand Reset_Click { private set; get; }
#endregion
2.VM中绑定函数
#region 构造函数
/// <summary>
/// Initializes a new instance of the UsermanageViewModel class.
/// </summary>
public UserManageViewModel()
{
this.Reset_Click = new RelayCommand(PasswordReset);
}
#endregion
3.VM中创建对应函数
1 #region 绑定命令
2 private void PasswordReset()
3 {
4 MessageBox.Show("功能建设中");
5 }
6 #endregion
4.后台代码xaml.cs中调用
((UserManageViewModel)this.DataContext).Reset_Click.Execute(null);
转载于:https://www.cnblogs.com/bloggonggy/archive/2013/06/01/3111806.html