C# 调用方法的自动生成事件,如按钮命令tabitem wpf

C# 调用方法的自动生成事件,如按钮命令tabitem wpf,c#,wpf,mvvm,command,C#,Wpf,Mvvm,Command,我需要创建验证:如果所有字段都已填充 IsEnabled=true; //in xaml for next tabItem IsEnabled=false; //in xaml for next tabItem 如果不是所有字段都已填充 IsEnabled=true; //in xaml for next tabItem IsEnabled=false; //in xaml for next tabItem 我希望在用户查看TabItems(Control\Window)时始终进行验证。

我需要创建验证:如果所有字段都已填充

IsEnabled=true; //in xaml for next tabItem
IsEnabled=false; //in xaml for next tabItem
如果不是所有字段都已填充

IsEnabled=true; //in xaml for next tabItem
IsEnabled=false; //in xaml for next tabItem
我希望在用户查看TabItems(Control\Window)时始终进行验证。 我想要像巴顿的命令一样

public WizardCommand(Action execute, Func<bool> canExecute)
{
   if (execute == null)
      throw new ArgumentNullException("execute");

   this.execute = execute;

   if (canExecute != null)
      this.canExecute = canExecute;
}
公共向导命令(操作执行,函数执行)
{
if(execute==null)
抛出新的ArgumentNullException(“执行”);
this.execute=execute;
如果(canExecute!=null)
this.canExecute=canExecute;
}
按钮的命令调用向导命令(操作执行,函数执行)在按钮处于窗体时自动执行。
如何使tabitem像绑定mvvm上的button with命令一样工作?

有什么问题?在视图模型中创建
IsEnabled
属性,将其绑定到
TabItem.IsEnabled
。然后每次验证发生时都更改该属性。当验证发生时-这就是问题所在。如何生成这个“当验证发生时”在字段更改时调用验证方法否,我有50个字段,我需要类似command onlyWPF的东西支持三种验证方法:使用Valuation规则验证、使用Exception验证、使用
IDataErrorInfo验证。有许多文章/博客条目描述了这些方法。这个问题也会有帮助: