Reputation: 103
I'm experimenting with MVVM Light for an application which acquires data from sensors. The sensor model exposes properties and methods. Some of these methods take arguments and return data. Example,
public double GetVelocity(int AxisNo)
{
Do something;
return double_data;
}
How do I use RelayCommand<T>
to pass a parameter from a bound control and bind the return value to another control displaying it?
Thanks.
Upvotes: 1
Views: 607
Reputation: 3231
You can use CommandParameter
to pass a parameter to a command.
You can't return a value, but you can set a property that raises NotifyPropertyChanged
, and bind something to that property.
Returning a value would imply that the view has some intelligence. You're better to think of the view as just displaying the state of the ViewModel, which translates the properties of the Model into values that are suitable for display.
Similarly, commands should live in the ViewModel, as they aren't intrinsic to the model.
Upvotes: 3