小弟看不懂一段程序:[Bindable(true)]
public int MyProperty {
get {
// Insert code here.
return 0;
}
set {
// Insert code here.
}
}指定这个属性用于绑定,
可本人不懂这个属性绑定与不绑定有什么区别,,,
请好心有解译一下!
public int MyProperty {
get {
// Insert code here.
return 0;
}
set {
// Insert code here.
}
}指定这个属性用于绑定,
可本人不懂这个属性绑定与不绑定有什么区别,,,
请好心有解译一下!
是不是这个意思:
class.MyProperty=数据源:
有关此类型所有成员的列表,请参阅 BindableAttribute 成员。
System.Object
System.Attribute
System.ComponentModel.BindableAttribute
[Visual Basic]
<AttributeUsage(AttributeTargets.All)>
NotInheritable Public Class BindableAttribute
Inherits Attribute
[C#]
[AttributeUsage(AttributeTargets.All)]
public sealed class BindableAttribute : Attribute
[C++]
[AttributeUsage(AttributeTargets::All)]
public __gc __sealed class BindableAttribute : public Attribute
[JScript]
public
AttributeUsage(AttributeTargets.All)
class BindableAttribute extends Attribute
线程安全
此类型的所有公共静态(Visual Basic 中为 Shared)成员对多线程操作而言都是安全的。但不保证任何实例成员是线程安全的。
备注
您可以为控件上的多个属性指定该特性。
用布尔值初始化 BindableAttribute 类的新实例。
如果使用值 true 的 BindableAttribute 构造函数标记属性,则应引发该属性的属性更改通知。这意味着如果 Bindable 是 Yes,则支持双向数据绑定。如果 Bindable 是 No,则您仍可以绑定到该属性,但它不应该显示在默认的要绑定到的属性集中,因为它不一定引发属性更改通知。
注意 当使用值 true 的 BindableAttribute 构造函数标记属性时,此特性的值被设置为常量成员 Yes。对于使用值 false 的 BindableAttribute 构造函数标记的属性,该值为 No。因此,若要在代码中检查该特性的值,必须将该特性指定为 BindableAttribute.Yes 或 BindableAttribute.No。
警告 您只能在设计时使用该特性。您在运行时可以随意向任何属性进行绑定。
有关更多信息,请参见特性概述和利用属性扩展元数据。
示例
[Visual Basic, C#, C++] 下面的示例将属性标记为适于将数据绑定到的属性。
[Visual Basic]
<Bindable(True)> _
Public Property MyProperty() As Integer
Get
' Insert code here.
Return 0
End Get
Set
' Insert code here.
End Set
End Property
[C#]
[Bindable(true)]
public int MyProperty {
get {
// Insert code here.
return 0;
}
set {
// Insert code here.
}
}