Class TypeExtension
Implements a markup extension that returns a Type based on a string input.
Implements
Inherited Members
Namespace: System.Windows.Markup
Assembly: OpenSilver.dll
Syntax
[TypeConverter(typeof(TypeExtensionConverter))]
public class TypeExtension : MarkupExtension, IMarkupExtension<object>
Constructors
| Improve this Doc View SourceTypeExtension()
Initializes a new instance of the TypeExtension class.
Declaration
public TypeExtension()
TypeExtension(String)
Initializes a new instance of the TypeExtension class, initializing the TypeName value based on the provided typeName string.
Declaration
public TypeExtension(string typeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | typeName | A string that identifies the type to make a reference to. This string uses the format prefix:className. prefix is the mapping prefix for a XAML namespace, and is only required to reference types that are not mapped to the default XAML namespace. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Attempted to specify typeName as null. |
TypeExtension(Type)
Initializes a new instance of the TypeExtension class, declaring the type directly.
Declaration
public TypeExtension(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type to be represented by this TypeExtension. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | type is null |
Properties
| Improve this Doc View SourceType
Gets or sets the type information for this extension.
Declaration
public Type Type { get; set; }
Property Value
Type | Description |
---|---|
System.Type | The established type. For runtime purposes, this may be null for get access, but cannot be set to null. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Attempted to set to null. |
TypeName
Gets or sets the type name represented by this markup extension.
Declaration
public string TypeName { get; set; }
Property Value
Type | Description |
---|---|
System.String | A string that identifies the type. This string uses the format prefix:className. (prefix is the mapping prefix for an XML namespace and is only required to reference types that are not mapped to the default XML namespace for WPF (http://schemas.microsoft.com/winfx/2006/xaml/presentation). |
Methods
| Improve this Doc View SourceProvideValue(IServiceProvider)
Returns an object that should be set on the property where this extension is applied. For TypeExtension, this is the Type value as evaluated for the requested type name.
Declaration
public override object ProvideValue(IServiceProvider serviceProvider)
Parameters
Type | Name | Description |
---|---|---|
System.IServiceProvider | serviceProvider | Object that can provide services for the markup extension. The provider is expected to provide a service for IXamlTypeResolver. |
Returns
Type | Description |
---|---|
System.Object | The Type to set on the property where the extension is applied. |
Overrides
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | member value for the extension is null. |
System.ArgumentException | Some part of the typeName string did not parse properly. -or- serviceProvider did not provide a service for IXamlTypeResolver -or- typeName value did not resolve to a type. |
System.ArgumentNullException | serviceProvider is null. |