A property element cannot be the direct content of another property element

This error occurs when you try to use property element syntax within a property element. For more information, see XAML Syntax Terminology

This error is raised when the file is a valid XML document, but is not a well-formed XAML document.

Error ID: XAML0420

To correct this error

  • Using element syntax, declare an object of the type corresponding to the property. Assign the value of this nested element by using object element syntax.

Example

The following code example shows how to use property element syntax to assign the Content property. Uncomment the property element to raise error XAML0420.

<Button>
    <Button.ContextMenu>
        <!-- Uncomment the following line to raise error XAML0420. -->
        <!-- <Grid.Column/> -->
        <ContextMenu>
            <MenuItem Header="1">First item</MenuItem>
            <MenuItem Header="2">Second item</MenuItem>
        </ContextMenu>
    </Button.ContextMenu>

    Right-click Here

</Button>

See Also

Concepts

XAML Errors and Help

XAML Syntax Terminology

Other Resources

XAML