galasoft mvvm テンプレートを使用して、wpf にかなり新しい。同じことを行う 2 つのリレー コマンドがありますが、異なるプロパティを設定する必要があります。
このようなことはできますか?
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);
}