Editja

NameReferenceConverter Class

Definition

Provides type conversion to convert a string name into an object reference to the object with that name, or to return the name of an object from the object graph.

public ref class NameReferenceConverter : System::ComponentModel::TypeConverter
public class NameReferenceConverter : System.ComponentModel.TypeConverter
type NameReferenceConverter = class
    inherit TypeConverter
Public Class NameReferenceConverter
Inherits TypeConverter
Inheritance
NameReferenceConverter

Remarks

This class provides a type converter wrapper around two services.

The ConvertFrom implementation uses IXamlNameResolver service from context to perform the resolution of an object by name in XAML. This is part of the relevant XAML reader and XAML writer implementations in .NET Framework XAML Services. Proper function of this converter requires that the IXamlNameResolver service is available from service context.

The ConvertTo implementation uses IXamlNameProvider service from context to perform the resolution of a reference name for an object during save/serialization. This is part of the relevant reader and writer implementations and their context. Proper function of this converter requires that there be an underlying IXamlNameProvider service available.

This type converter implementation is atypical for the TypeConverter base type because it is not scoped to a discrete conversion type. It can potentially convert any object to and from a referencing name so long as that object could have a name assigned to it in XAML, and the supporting context has the necessary services to return results.

As part of general services support, the System.Xaml base implementation of XamlObjectWriter and XamlXmlWriter provide IXamlNameProvider and IXamlNameResolver services for use by NameReferenceConverter. The name basis for these services uses either x:Name or a RuntimeNamePropertyAttribute attributed alias property.

Constructors

Name Description
NameReferenceConverter()

Initializes a new instance of the NameReferenceConverter class.

Methods

Name Description
CanConvertFrom(ITypeDescriptorContext, Type)

Returns whether this converter can convert an object of one type to another object.

CanConvertTo(ITypeDescriptorContext, Type)

Returns a value that indicates whether the converter can convert an object to the specified destination type.

ConvertFrom(ITypeDescriptorContext, CultureInfo, Object)

Converts the provided object to another object, using the specified context and culture information.

ConvertTo(ITypeDescriptorContext, CultureInfo, Object, Type)

Converts an object to the specified type. This is intended to return XAML reference names for objects in an object graph.

Applies to

See also