BindableProperty.CreateAttached 方法

定义

重载

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

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

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

已否决。 请勿使用。

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

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

public static Xamarin.Forms.BindableProperty CreateAttached (string propertyName, Type returnType, Type declaringType, object defaultValue, Xamarin.Forms.BindingMode defaultBindingMode = Xamarin.Forms.BindingMode.OneWay, 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 CreateAttached : 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.BindableProperty

参数

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。

返回

新创建的附加 BindableProperty。

适用于

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

注意

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

已否决。 请勿使用。

[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[System.Obsolete("CreateAttached<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
public static Xamarin.Forms.BindableProperty CreateAttached<TDeclarer,TPropertyType> (System.Linq.Expressions.Expression<Func<Xamarin.Forms.BindableObject,TPropertyType>> staticgetter, TPropertyType defaultValue, Xamarin.Forms.BindingMode defaultBindingMode = Xamarin.Forms.BindingMode.OneWay, 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<Xamarin.Forms.BindableObject,TPropertyType> defaultValueCreator = default);
static member CreateAttached : System.Linq.Expressions.Expression<Func<Xamarin.Forms.BindableObject, '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<Xamarin.Forms.BindableObject, 'PropertyType> -> Xamarin.Forms.BindableProperty

类型参数

TDeclarer

声明对象的类型。

TPropertyType

属性的类型。

参数

staticgetter
System.Linq.Expressions.Expression<System.Func<BindableObject,TPropertyType>>

标识静态方法的表达式,该方法使用此 BindableProperty 作为后备存储返回属性的值。

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<BindableObject,TPropertyType>

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

返回

新创建的 BindableProperty。

属性
System.ComponentModel.EditorBrowsableAttribute System.ObsoleteAttribute

注解

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

适用于