DependencyPropertyConverter.CanConvertFrom(ITypeDescriptorContext, Type) 方法

定义

确定能否将指定类型的对象转换为 DependencyProperty 的实例。Determines whether an object of the specified type can be converted to an instance of DependencyProperty.

public:
 override bool CanConvertFrom(System::ComponentModel::ITypeDescriptorContext ^ context, Type ^ sourceType);
public override bool CanConvertFrom (System.ComponentModel.ITypeDescriptorContext context, Type sourceType);
override this.CanConvertFrom : System.ComponentModel.ITypeDescriptorContext * Type -> bool
Public Overrides Function CanConvertFrom (context As ITypeDescriptorContext, sourceType As Type) As Boolean

参数

context
ITypeDescriptorContext

一种格式上下文,可提供有关要从中调用此转换器的环境的信息。A format context that provides information about the environment from which this converter is being invoked.

sourceType
Type

要进行计算以供转换的类型。The type being evaluated for conversion.

返回

如果此转换器能够执行该操作,则为 true;否则为 falsetrue if this converter can perform the operation; otherwise, false.

注解

类仅将字符串转换为的DependencyProperty实例。 DependencyPropertyConverterThe DependencyPropertyConverter class only converts a string to an instance of DependencyProperty. 因此, 只有sourceTypeStringtrue返回。Therefore only a sourceType of String returns true.

context此实现不使用。context is not used by this implementation.

适用于