后台代码绑定到目标CLR属性 [英] Databinding to a target CLR property in code-behind

查看:66
本文介绍了后台代码绑定到目标CLR属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

绑定到依赖项属性在代码隐藏中很容易.您只需创建一个新的 System.Windows.Data.Binding 对象,然后调用目标依赖对象的 SetBinding 方法.

Binding to a Dependency Property is easy in code-behind. You just create a new System.Windows.Data.Binding object, and then call the target dependency object's SetBinding method.

但是,当我们要绑定的属性是CLR属性并且您不能为 SetBinding 提供 DependencyProperty 参数时,该怎么办?有没有办法使用CLR属性作为绑定目标?

But how do you do this when the property which we're binding is a CLR property and you can't provide a DependencyProperty argument to SetBinding? Is there a way to use a CLR property as a binding target?

(如果相关),该对象实现 INotifyPropertyChanged .

The object implements INotifyPropertyChanged, if that's relevant.

推荐答案

绑定目标必须是依赖项属性!这是数据绑定工作的唯一要求!

Binding targets MUST be dependency properties! That's the only requirement for databinding to work!

在此处了解更多信息

这篇关于后台代码绑定到目标CLR属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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