Passing a parameter using RelayCommand defined in the ViewModel (from Josh Smith example)

后端 未结 6 517
既然无缘
既然无缘 2020-12-09 02:57

I would like to pass a parameter defined in the XAML (View) of my application to the ViewModel class by using the RelayCommand. I followed Josh Smith\'s excellent article o

6条回答
  •  盖世英雄少女心
    2020-12-09 03:24

    You'll pass the param in the lambda to the command like so:

    if (_aCommandWithAParameter == null)
    {           
        _aCommandWithAParameter = new RelayCommand(               
            param => this.CommandWithAParameter(param)
            );        
    }
    

提交回复
热议问题