Share via


Type '{0}' is not usable as an object element

Type '{0}' is not usable as an object element because it is not public or does not define a public parameterless constructor or a type converter.

This error occurs when you attempt to instantiate a type by using element syntax, but the type does not have a public constructor, a type converter, or is not public. This may be caused by using an abstract type.

This error is raised when the file is a well-formed XAML document, but contains one or more type mismatches.

Error ID: XAML0507

To correct this error

  • Use a type which provides a public constructor or a type converter. If the type is abstract, use a derived concrete type.

To correct this error

  • If the error is raised because of your custom type, consider providing a public constructor or a type converter for the type.

Example

The following code example shows an attempt to create a Freezable object by using element syntax. The constructor for the Freezable type is protected. Uncomment the declaration to raise error XAML0507.

<!-- Uncomment the following line to raise error XAML0507. -->
<!-- <Button> <Freezable /> </Button> -->

See Also

Concepts

XAML Errors and Help

Other Resources

XAML