OpacityConverter.ConvertFrom(ITypeDescriptorContext, CultureInfo, Object) OpacityConverter.ConvertFrom(ITypeDescriptorContext, CultureInfo, Object) OpacityConverter.ConvertFrom(ITypeDescriptorContext, CultureInfo, Object) OpacityConverter.ConvertFrom(ITypeDescriptorContext, CultureInfo, Object) Method

定义

将指定对象转换为转换器的本机类型。Converts the specified object to the converter's native type.

public:
 override System::Object ^ ConvertFrom(System::ComponentModel::ITypeDescriptorContext ^ context, System::Globalization::CultureInfo ^ culture, System::Object ^ value);
public override object ConvertFrom (System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value);
override this.ConvertFrom : System.ComponentModel.ITypeDescriptorContext * System.Globalization.CultureInfo * obj -> obj
Public Overrides Function ConvertFrom (context As ITypeDescriptorContext, culture As CultureInfo, value As Object) As Object

参数

context
ITypeDescriptorContext ITypeDescriptorContext ITypeDescriptorContext ITypeDescriptorContext

提供类型转换器上下文信息的 ITypeDescriptorContextA ITypeDescriptorContext that provides information about the context of a type converter.

culture
CultureInfo CultureInfo CultureInfo CultureInfo

用于转换的区域设置信息。The locale information for the conversion.

value
Object Object Object Object

要转换的对象。The object to convert.

返回

表示转换的 valueObjectAn Object that represents the converted value.

异常

该对象不是转换所支持的类型。The object was not a supported type for the conversion.

value 未能正确地转换为类型 Doublevalue could not be properly converted to type Double.

-or- 得到的转换后的 value 小于百分之零或大于百分之百。The resulting converted value was less than zero percent or greater than one hundred percent.

注解

方法专用于将表示百分比String或小数部分的值转换为其对应Double的值, 这些值将不透明度表示为百分比。 ConvertFromThe ConvertFrom method is specialized to convert String values that represent percentages or decimal fractions to their corresponding Double values, which represent the opacity as a percentage. 以外的类型将传递给此方法的基类实现。 StringTypes other than String are passed to the base class implementation of this method.

继承者说明

重写该方法以提供您自己的转换需求。Override this method to provide your own conversion requirements.

可以使用context参数来提取有关从中调用此转换器的环境的其他信息。You can use the context parameter to extract additional information about the environment this converter is being invoked from. 参数可以为null, 因此应始终验证内容。The parameter may be null, so you should always verify the contents. 此外, 上的ITypeDescriptorContext属性还可能返回。 nullAlso, properties on the ITypeDescriptorContext may also return null.

适用于

另请参阅