This documentation is archived and is not being maintained.

x:XData XAML Directive Element

The x:XData XAML directive element places XML data islands within an XAML page. XML elements within this directive element will not be treated as if they are a part of the WPF namespace, and can contain arbitrary well-formed XML.

<XmlDataProvider ...>


Required. The single root element of the enclosed data island. Without a single root, the x:XData is invalid as a data source.


Optional. XML that represents your data. Any number of elements can be contained as element data, nested elements can be contained in other elements, and so on, subject to the general rules of XML.

The x:XData element is primarily used as a child element of an XmlDataProvider, or alternatively as the child element of the XmlSerializer property of XmlDataProvider property expressed in object property syntax.

The XML elements within this directive element can re-declare all possible namespaces and prefixes within the data island. Typically the data should redefine the base XML namespace within the data island to be a new default XML namespace (set to an empty string). This is easiest for simple data islands because the XPath expressions used to reference and bind to the data can avoid inclusion of prefixes. More complex data islands may choose to define multiple prefixes for the data, and to use a specific prefix for the XML namespace at the root. In this case all XPath expression references will need to include the appropriate namespace-mapped prefix.

Technically, x:XData can be used as the content of any property of type IXmlSerializable. However, XmlDataProvider.XmlSerializer is the only prominent implementation.