C# 动作委托在mvvm wpf中发送空值

C# 动作委托在mvvm wpf中发送空值,c#,wpf,mvvm,C#,Wpf,Mvvm,下面的代码是我的按钮命令 class ButtonCommand : ICommand { private Action<object> whatToExecute; public ButtonCommand(Action<object> whatToExecute) { this.whatToExecute = whatToExecute; } public event EventHandler CanE

下面的代码是我的按钮命令

class ButtonCommand : ICommand
{
    private Action<object> whatToExecute;



    public ButtonCommand(Action<object> whatToExecute)
    {
        this.whatToExecute = whatToExecute;

    }

    public event EventHandler CanExecuteChanged;

    public bool CanExecute(object parameter)
    {
        return true;
    }

    public void Execute(object parameter)
    {
        //parameter have value          
        whatToExecute(parameter);

    }
}
在插入方法和删除方法中,personType值为null
我怎样才能解决这个问题?

不清楚你在问什么。
Insert(PersonType)
Delete(PersonType)
中的
PersonType
应该是什么?是否有属性
PersonType
?它是我的数据的类,这个问题非常重要,但它不会编译?请向我们展示调用insertCommand/deleteCommand命令的代码?PersonTypeViewModel构造函数
PersonType personType;
    private ButtonCommand insertCommand;
    private ButtonCommand deleteCommand;

    public event PropertyChangedEventHandler PropertyChanged;

    public PersonTypeViewModel()
    {
        personType = new PersonType();
        insertCommand = new ButtonCommand((p)=> { Insert(PersonType); });
        deleteCommand = new ButtonCommand((s) => { Delete(PersonType); });
    }

    public ICommand btnClickInsert
    {
        get
        {
            return insertCommand;
        }
    }

    public ICommand btnClickDelete
    {
        get
        {
            return deleteCommand;
        }
    }
    public void Insert(PersonType personType)
    {            
        if(this.personType.Insert(personType) == 1)
        {
            MessageBox.Show("Successfull Insert");
        }
        PropertyChanged(this, new PropertyChangedEventArgs("GetAll"));
    }

    public List<PersonType> GetAll
    {
        get
        {
            return personType.GetAll();
        }
    }

    public void Delete(PersonType personType)
    {
        if (this.personType.Delete(personType) == 1)
        {
            MessageBox.Show("Successfull Delete");
        }
        PropertyChanged(this, new PropertyChangedEventArgs("GetAll"));
    }
public PersonType()
   {
    int id { get; set; }
    string typeName { get; set; }
    string description { get; set; }
   }