Share via


BindableProperty.CreateReadOnly 方法

定义

创建 BindablePropertyKey 类的新实例。

public static Microsoft.Maui.Controls.BindablePropertyKey CreateReadOnly (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 CreateReadOnly : 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 CreateReadOnly (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。

返回

适用于