Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

XamlType.CanAssignTo Method

Returns a value that indicates whether an instance of this XamlType has the specified XamlType in its list of assignable types.

Namespace:  System.Xaml
Assembly:  System.Xaml (in System.Xaml.dll)
public virtual bool CanAssignTo(
	XamlType xamlType
)

Parameters

xamlType
Type: System.Xaml.XamlType

The type to check against the current XamlType .

Return Value

Type: System.Boolean
true if xamlType is in the assignable types list; otherwise, false.

Although the assignable type does not have all the capabilities of the reference type, you can use it for assignment. For example, you can use assignment to make type matches for the values of a property. The concept of assignable types in XAML is similar to the concept of casting up in the CLR type system. For example, under a CLR type system, every type has an Object in its assignable type list.

If one of the two XamlType instances that are used for comparison has IsUnknown equal to true, this method has a special Unknown mode that returns true if the two XamlType instances are equivalent.

The default implementation uses the CLR Type from UnderlyingType for this XamlType and the input XamlType, and calls IsAssignableFrom. Override this method if you want a different determination of assignable types.

Passing a null xamlType does not throw an exception and always returns false.

Security noteSecurity Note

CanAssignTo is virtual, and therefore, can be overridden. The override has the potential (whether for malicious purposes or otherwise) to change the assignability of a XAML type so that it no longer aligns in an expected way with the type-casting behavior of its underlying CLR type. For any security-critical checks of assignment operations and access, use the underlying CLR type instead.

.NET Framework

Supported in: 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.