The type '{0}' does not support direct content

This error occurs when you try to use object element syntax with a type which does not have a content property specified by the ContentPropertyAttribute. For more information, see XAML Syntax In Detail.

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

Error ID: XAML0502

Note

This error message also applies to the Silverlight Designer.

To correct this error

  • Remove the object element assignment and use attribute syntax instead.

To correct this error

Example

The following code example shows how to assign direct content to a Button control. The second declaration shows an attempt to assign direct content to an Ellipse object, which does not have a content property specified by the ContentPropertyAttribute. Uncomment the Ellipse declaration to raise error XAML0502.

<Button>OK</Button>

<!-- Uncomment the following line to raise error XAML0502. -->
<!-- <Ellipse>OK</Ellipse> -->

See Also

Reference

ContentPropertyAttribute

Concepts

XAML Errors and Help

XAML Syntax In Detail

Other Resources

XAML in WPF

XAML in Silverlight