Compartir a través de


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 xmlns namespace, and can contain arbitrary well-formed XML.

XAML Object Element Usage

<XmlDataProvider ...>
  <x:XData>
    <elementDataRoot>
      [elementData]
    </elementDataRoot>...
  </x:XData>
</XmlDataProvider>

XAML Values

elementDataRoot

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

[elementData]

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.

Dependencies

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.

Remarks

The XML elements within this directive element can redeclare all possible namespaces and prefixes within the data island. Typically the data should redefine the base xmlns within the data island to be the new default xmlns (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 xmlns 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.

See Also

Reference

Binding Markup Extension
XmlDataProvider

Concepts

Data Binding Overview