Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
此博客条目描述了使用视图绑定来替代 XAML 绑定。我喜欢基于约定的接线:
this.OneWayBind(ViewModel, x => x.FooMirror);
如果我想绑定到 TextBox 的 Text 属性:
this.Bind(ViewModel, x => x.SomeText, x => x.SomeText.Text);
但是,我有一个要绑定的附加属性(用于附加行为模式的实现)。如何使用 View Bindings 语法绑定到附加属性?
Binding 目前对 XAML 附加属性一无所知 - 您可能必须通过执行以下操作来解决此问题:
this.WhenAny(x => x.ViewModel.SomeCoolProperty, x => x.Value) .Subscribe(x => theControl.SetValue(AttachedObject.MyAttachedProperty, x);