Share via


BindableProperty.CreateAttachedReadOnly 方法

定义

为附加的只读属性创建 BindableProperty 类的新实例。

public static Microsoft.Maui.Controls.BindablePropertyKey CreateAttachedReadOnly (string propertyName, Type returnType, Type declaringType, object defaultValue, Microsoft.Maui.Controls.BindingMode defaultBindingMode = Microsoft.Maui.Controls.BindingMode.OneWayToSource, Microsoft.Maui.Controls.BindableProperty.ValidateValueDelegate validateValue = default, Microsoft.Maui.Controls.BindableProperty.BindingPropertyChangedDelegate propertyChanged = default, Microsoft.Maui.Controls.BindableProperty.BindingPropertyChangingDelegate propertyChanging = default, Microsoft.Maui.Controls.BindableProperty.CoerceValueDelegate coerceValue = default, Microsoft.Maui.Controls.BindableProperty.CreateDefaultValueDelegate defaultValueCreator = default);
static member CreateAttachedReadOnly : string * Type * Type * obj * Microsoft.Maui.Controls.BindingMode * Microsoft.Maui.Controls.BindableProperty.ValidateValueDelegate * Microsoft.Maui.Controls.BindableProperty.BindingPropertyChangedDelegate * Microsoft.Maui.Controls.BindableProperty.BindingPropertyChangingDelegate * Microsoft.Maui.Controls.BindableProperty.CoerceValueDelegate * Microsoft.Maui.Controls.BindableProperty.CreateDefaultValueDelegate -> Microsoft.Maui.Controls.BindablePropertyKey
Public Shared Function CreateAttachedReadOnly (propertyName As String, returnType As Type, declaringType As Type, defaultValue As Object, Optional defaultBindingMode As BindingMode = Microsoft.Maui.Controls.BindingMode.OneWayToSource, Optional validateValue As BindableProperty.ValidateValueDelegate = Nothing, Optional propertyChanged As BindableProperty.BindingPropertyChangedDelegate = Nothing, Optional propertyChanging As BindableProperty.BindingPropertyChangingDelegate = Nothing, Optional coerceValue As BindableProperty.CoerceValueDelegate = Nothing, Optional defaultValueCreator As BindableProperty.CreateDefaultValueDelegate = Nothing) As BindablePropertyKey

参数

propertyName
String

BindableProperty 的名称。

returnType
Type

属性的类型。

declaringType
Type

声明对象的类型。

defaultValue
Object

属性的默认值。

defaultBindingMode
BindingMode

如果未指定 BindingMode,则在 SetBinding() 上使用 BindingMode。 此参数可选。 默认值为 BindingMode.OneWay。

validateValue
BindableProperty.ValidateValueDelegate

设置值时要运行的委托。 此参数可选。 默认值为 NULL。

propertyChanged
BindableProperty.BindingPropertyChangedDelegate

值已更改时要运行的委托。 此参数可选。 默认值为 NULL。

propertyChanging
BindableProperty.BindingPropertyChangingDelegate

值将更改时要运行的委托。 此参数可选。 默认值为 NULL。

coerceValue
BindableProperty.CoerceValueDelegate

用于强制转换值范围的委托。 此参数可选。 默认值为 NULL。

defaultValueCreator
BindableProperty.CreateDefaultValueDelegate

用于初始化引用类型的默认值的 Func。

返回

新创建的附加只读 BindableProperty。

注解

附加属性是绑定到其父对象以外的对象的可绑定属性。 通常,它们用于表和网格中的子项,其中有关项位置的数据由其父项维护,但必须从子项本身访问。

适用于