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

时间:2018-05-01 19:56:07

标签: c# wpf mvvm

以下代码适用于我的ButtonCommand

Map

以下代码适用于此类中的PersonViewModel我从视图中获取数据并调用连接到Insert Method和Delete方法的委托并将它们传递给ButtonCommand类:

java.sql.SQLException: No suitable driver found for jdbc:mysql//localhost:3306/ci?useSSL=false
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at com.practico2.test.TestJDBC.main(TestJDBC.java:17)

此代码适用于我的PersonType:

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);

    }
}

在Insert方法和Delete方法中,personType值为null 我该如何解决这个问题?

0 个答案:

没有答案