问题
This Blog Entry describes using View Bindings as a replacement for XAML Bindings. I like the convention-based wire-up:
this.OneWayBind(ViewModel, x => x.FooMirror);
And if I want to bind to a TextBox's Text property:
this.Bind(ViewModel, x => x.SomeText, x => x.SomeText.Text);
However I have an attached property which I would like to bind to (for an implementation of the attached behaviour pattern). How do I use the View Bindings syntax to bind to an attached property?
回答1:
Binding doesn't know anything about XAML attached properties at the moment - you might have to work around this by doing something like:
this.WhenAny(x => x.ViewModel.SomeCoolProperty, x => x.Value)
.Subscribe(x => theControl.SetValue(AttachedObject.MyAttachedProperty, x);
来源:https://stackoverflow.com/questions/14275141/reactiveui-view-bindings-to-attached-property