Closed bradphelan closed 12 years ago
I just discovered BindTo :)
Hm, I would do this as:
var model = GetWindSpeedModel();
model.WhenAny(x => x.WindSpeed, x => x.Value.ToString("00.00"))
.BindTo(theView, x => x.Text);
But it doesn't work with winform, only wpf. the dispatcher logic is all wrong. I'm working on a winforms addition to reactive ui at the moment. It avoids properties and just uses observables.
I have created a helper class called ObservableBinding which is like a mini view model with only a single property Value. I've added an extension method for binding ObservableBindings to controls and the resulting code is much simpler for quickly binding plain old objects to UI elements, at least for output only cases.
For example
Note that I don't have to create a ViewModel class to hold my binding. I can transform and bind directly from my domain object.
The class is ( in VB.NET sorry ) but quite simple