ReactiveUI View Bindings to attached property

2019-04-15 23:40发布

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?

标签: reactiveui
1条回答
乱世女痞
2楼-- · 2019-04-16 00:27

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);
查看更多
登录 后发表回答