Fairly new to wpf, using the galasoft mvvm templates.
I have two relaycommands that do the same thing, but they need to set different properties.
Can I do something like this?
public RelayCommand OpenDestinationCommand { get; private set; }
public RelayCommand OpenSourceCommand { get; private set; }
public MainViewModel(IDataService dataService)
{
OpenSourceCommand = new RelayCommand(() => GetPath(SourcePathPropertyName));
OpenDestinationCommand = new RelayCommand(() => GetPath(DestinationPathPropertyName));
}
private void GetPath(string PropertyName) {
//show a dialog, get the path they select
string newPath = GetPathFromDialog();
//what should this look like? Is this possible?
var Property = GetPropertyByName(PropertyName);
Property.Set(newPath);
}
Shoulda googled first.
adapted from http://geekswithblogs.net/shahed/archive/2006/11/19/97548.aspx