0

如何在set中使用relay命令,我使用下面的方式,在set方法上抛出接口bug

     public RelayCommand ChartCommand
    {

        set
        {
            ChartCommand = new RelayCommand<string>(e => ExecuteChartCommand(e));

        }
    }
    public void ExecuteChartCommand(string vendor)
    {

    }
4

1 回答 1

2

你真的应该这样做:

    private RelayCommand<string> m_ChartCommand;
    public RelayCommand<string> ChartCommand
    {    
        get
        {
            return m_ChartCommand ?? (m_ChartCommand = new RelayCommand<string>(e => ExecuteChartCommand(e));    
        }
    }

    public void ExecuteChartCommand(string vendor)
    {

    }

.

于 2012-11-12T11:19:14.473 回答