在代码隐藏中将数据绑定到CLR属性 [英] Databinding to CLR property in code-behind

查看:93
本文介绍了在代码隐藏中将数据绑定到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属性并且您不能提供 DependencyProperty SetBinding 的c $ c>参数?

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?

编辑:该对象实现 INotifyPropertyChanged (如果相关)。

The object implements INotifyPropertyChanged, if that's relevant.

推荐答案

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

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

在此处了解更多信息:

  • http://msdn.microsoft.com/en-us/library/ms531387(VS.85).aspx
  • http://msdn.microsoft.com/en-us/library/ms752347.aspx

这篇关于在代码隐藏中将数据绑定到CLR属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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