Share via


BindableProperty.CreateReadOnly 方法

定义

重载

CreateReadOnly(String, Type, Type, Object, BindingMode, BindableProperty+ValidateValueDelegate, BindableProperty+BindingPropertyChangedDelegate, BindableProperty+BindingPropertyChangingDelegate, BindableProperty+CoerceValueDelegate, BindableProperty+CreateDefaultValueDelegate)

创建 BindablePropertyKey 类的新实例。

CreateReadOnly<TDeclarer,TPropertyType>(Expression<Func<TDeclarer, TPropertyType>>, TPropertyType, BindingMode, BindableProperty.ValidateValueDelegate<TPropertyType>, BindableProperty.BindingPropertyChangedDelegate<TPropertyType>, BindableProperty.BindingPropertyChangingDelegate<TPropertyType>, BindableProperty.CoerceValueDelegate<TPropertyType>, BindableProperty.CreateDefaultValueDelegate<TDeclarer, TPropertyType>)
已过时.

已否决。 请勿使用。

CreateReadOnly(String, Type, Type, Object, BindingMode, BindableProperty+ValidateValueDelegate, BindableProperty+BindingPropertyChangedDelegate, BindableProperty+BindingPropertyChangingDelegate, BindableProperty+CoerceValueDelegate, BindableProperty+CreateDefaultValueDelegate)

创建 BindablePropertyKey 类的新实例。

public static Xamarin.Forms.BindablePropertyKey CreateReadOnly (string propertyName, Type returnType, Type declaringType, object defaultValue, Xamarin.Forms.BindingMode defaultBindingMode = Xamarin.Forms.BindingMode.OneWayToSource, Xamarin.Forms.BindableProperty.ValidateValueDelegate validateValue = default, Xamarin.Forms.BindableProperty.BindingPropertyChangedDelegate propertyChanged = default, Xamarin.Forms.BindableProperty.BindingPropertyChangingDelegate propertyChanging = default, Xamarin.Forms.BindableProperty.CoerceValueDelegate coerceValue = default, Xamarin.Forms.BindableProperty.CreateDefaultValueDelegate defaultValueCreator = default);
static member CreateReadOnly : string * Type * Type * obj * Xamarin.Forms.BindingMode * Xamarin.Forms.BindableProperty.ValidateValueDelegate * Xamarin.Forms.BindableProperty.BindingPropertyChangedDelegate * Xamarin.Forms.BindableProperty.BindingPropertyChangingDelegate * Xamarin.Forms.BindableProperty.CoerceValueDelegate * Xamarin.Forms.BindableProperty.CreateDefaultValueDelegate -> Xamarin.Forms.BindablePropertyKey

参数

propertyName
System.String

BindableProperty 的名称。

returnType
System.Type

属性的类型。

declaringType
System.Type

声明对象的类型。

defaultValue
System.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。

返回

适用于

CreateReadOnly<TDeclarer,TPropertyType>(Expression<Func<TDeclarer, TPropertyType>>, TPropertyType, BindingMode, BindableProperty.ValidateValueDelegate<TPropertyType>, BindableProperty.BindingPropertyChangedDelegate<TPropertyType>, BindableProperty.BindingPropertyChangingDelegate<TPropertyType>, BindableProperty.CoerceValueDelegate<TPropertyType>, BindableProperty.CreateDefaultValueDelegate<TDeclarer, TPropertyType>)

注意

CreateReadOnly<> (generic) is obsolete as of version 2.1.0 and is no longer supported.

已否决。 请勿使用。

[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[System.Obsolete("CreateReadOnly<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
public static Xamarin.Forms.BindablePropertyKey CreateReadOnly<TDeclarer,TPropertyType> (System.Linq.Expressions.Expression<Func<TDeclarer,TPropertyType>> getter, TPropertyType defaultValue, Xamarin.Forms.BindingMode defaultBindingMode = Xamarin.Forms.BindingMode.OneWayToSource, Xamarin.Forms.BindableProperty.ValidateValueDelegate<TPropertyType> validateValue = default, Xamarin.Forms.BindableProperty.BindingPropertyChangedDelegate<TPropertyType> propertyChanged = default, Xamarin.Forms.BindableProperty.BindingPropertyChangingDelegate<TPropertyType> propertyChanging = default, Xamarin.Forms.BindableProperty.CoerceValueDelegate<TPropertyType> coerceValue = default, Xamarin.Forms.BindableProperty.CreateDefaultValueDelegate<TDeclarer,TPropertyType> defaultValueCreator = default) where TDeclarer : Xamarin.Forms.BindableObject;
static member CreateReadOnly : System.Linq.Expressions.Expression<Func<'Declarer, 'PropertyType>> * 'PropertyType * Xamarin.Forms.BindingMode * Xamarin.Forms.BindableProperty.ValidateValueDelegate<'PropertyType> * Xamarin.Forms.BindableProperty.BindingPropertyChangedDelegate<'PropertyType> * Xamarin.Forms.BindableProperty.BindingPropertyChangingDelegate<'PropertyType> * Xamarin.Forms.BindableProperty.CoerceValueDelegate<'PropertyType> * Xamarin.Forms.BindableProperty.CreateDefaultValueDelegate<'Declarer, 'PropertyType (requires 'Declarer :> Xamarin.Forms.BindableObject)> -> Xamarin.Forms.BindablePropertyKey (requires 'Declarer :> Xamarin.Forms.BindableObject)

类型参数

TDeclarer

声明对象的类型。

TPropertyType

属性的类型。

参数

getter
System.Linq.Expressions.Expression<System.Func<TDeclarer,TPropertyType>>

使用此 BindableProperty 作为后备存储,标识属性的 Getter 的表达式。

defaultValue
TPropertyType

BindableProperty 的默认值。

defaultBindingMode
BindingMode

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

validateValue
BindableProperty.ValidateValueDelegate<TPropertyType>

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

propertyChanged
BindableProperty.BindingPropertyChangedDelegate<TPropertyType>

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

propertyChanging
BindableProperty.BindingPropertyChangingDelegate<TPropertyType>

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

coerceValue
BindableProperty.CoerceValueDelegate<TPropertyType>

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

defaultValueCreator
BindableProperty.CreateDefaultValueDelegate<TDeclarer,TPropertyType>

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

返回

新创建的 BindablePropertyKey。

属性
System.ComponentModel.EditorBrowsableAttribute System.ObsoleteAttribute

注解

BindablePropertyKey 用于通过 SetValue () 或绑定限制对属性的写入访问。 通常也会定义 BindableProperty,以提供更广泛的读取访问权限

适用于