ReactiveUI 视图绑定到附加属性 [英] ReactiveUI View Bindings to attached property

查看:32
本文介绍了ReactiveUI 视图绑定到附加属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个博客条目 描述了使用视图绑定替代 XAML 绑定.我喜欢基于约定的接线:

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);

如果我想绑定到 TextBox 的 Text 属性:

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?

推荐答案

绑定目前对 XAML 附加属性一无所知 - 您可能必须通过执行以下操作来解决此问题:

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);

这篇关于ReactiveUI 视图绑定到附加属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆