Edytuj

Udostępnij za pośrednictwem


XamlMember.TypeConverter Property

Definition

Gets a XamlValueConverter<TConverterBase> object, which can be used for type conversion construction of XAML declared objects.

public:
 property System::Xaml::Schema::XamlValueConverter<System::ComponentModel::TypeConverter ^> ^ TypeConverter { System::Xaml::Schema::XamlValueConverter<System::ComponentModel::TypeConverter ^> ^ get(); };
public System.Xaml.Schema.XamlValueConverter<System.ComponentModel.TypeConverter> TypeConverter { get; }
member this.TypeConverter : System.Xaml.Schema.XamlValueConverter<System.ComponentModel.TypeConverter>
Public ReadOnly Property TypeConverter As XamlValueConverter(Of TypeConverter)

Property Value

A XamlValueConverter<TConverterBase> value, with a TypeConverter constraint on the generic.

Remarks

Calling TypeConverter invokes LookupTypeConverter or a specific override of that method. This behavior occurs when the initial internal reflection logic has not already set the information.

Implementations that return a non-null property value for TypeConverter are not necessarily a working TypeConverter. The following is a list of possible non-null return values for TypeConverter and what these values represent:

  • The return value reports a type converter that is attributed specifically to that member or more generally to the target type of the converter. This behavior is typically what most XAML type systems and XAML processors look for in order to instantiate a type converter and invoke its methods.

  • The return value reports a built-in value converter. These converters exist for certain internal operations that are performed by a XAML writer. In particular, these built-in value converters convert the raw attribute string values to the XAML language-level primitives. For the .NET Framework XAML Services implementation, these built-in type conversions often forward to a type converter that is defined in the System assembly. For example, a conversion for an Int32 value has built-in forwarded conversion, and therefore, the ConverterType value references Int32Converter.

  • The return value reports the special case of an unconstrained object model; that is, the XamlMember has a Type value of Object. In this case, the XamlValueConverter<TConverterBase> reports that the XamlValueConverter<TConverterBase>.Name is {Object}. However, ConverterInstance is null because no actual type or instance is available to perform this conversion. Instead, the object model behavior cannot be determined until run time, when the runtime of the specific technology determines the handling of its object graph.

If you can access a working TypeConverter from ConverterInstance, you can invoke its conversion methods. However, many conversion methods rely on service context. If you do not have the same service context available that the type converter expects for its typical role of writing objects for object graphs, the converter methods can throw exceptions.

Applies to