ReactiveUI View Bindings to attached property

北慕城南 提交于 2019-12-09 23:24:13

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!