如何将字符串从视图传递到viewmodel?我正在使用mvvm light,并且要将字符串从mainwindow.xaml传递给mainviewmodel。我尝试过类似的操作,但是没有用。
maiwindow.xaml:
<Button Command="{Binding Command, Mode=OneWay}"
CommandParameter="mystring" >
mainviewmodel:
private RelayCommand _command;
public RelayCommand Command
{
get
{
return _command
?? (_command= new RelayCommand(
() =>
{
string str = EventArgs.Empty.ToString();
//value of this string is "EventArgs.Empty"
}));
}
}