Reputation: 183
How do I wire up Viewmodel and model the ReactiveUI way? Is there even a ReactiveUI way (like this.RaiseAndSetIfChanged for normal properties)?
Regards Tobias
Edit: small Sample:
public class TestModel
{
public string TestName { get; set; }
}
public class TestViewModel : ReactiveObject
{
private TestModel _model;
public TestViewModel(TestModel model)
{
_model = model;
}
public TestName
{
get
{
return _model.Name;
}
set
{
//Update model value and raise PropertyChanged, but how?
}
}
}
Upvotes: 1
Views: 777
Reputation: 13888
public string TestName
{
get
{
return _model.TestName;
}
set
{
if (_model.TestName == value) return;
_model.TestName = value;
this.RaisePropertyChanged();
}
}
You could wrap this up in an extension method that takes an expression to know which field to update.
Upvotes: 1