This documentation is archived and is not being maintained.

XmlDataProvider.Source Property

Gets or sets the Uri of the XML data file to use as the binding source.

Namespace: System.Windows.Data
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public Uri Source { get; set; }
/** @property */
public Uri get_Source ()

/** @property */
public void set_Source (Uri value)

public function get Source () : Uri

public function set Source (value : Uri)

<object Source="Uri" .../>

Property Value

The Uri of the XML data file to use as the binding source. The default value is a null reference (Nothing in Visual Basic).

XmlDataProvider exposes the following ways to access XML data.

  • You can embed inline XML data using the XmlDataProvider class.

  • You can set this property to the Uri of an XML data file.

  • You can set the Document property to an XmlDocument.

If the Source property is set, then any inline XML data is discarded. If the Document property is set, then the Source property is cleared and any inline XML data is discarded.

Setting the following properties will implicitly cause this XmlDataProvider object to refresh: Source, Document, XmlNamespaceManager, and XPath. When changing multiple refresh-causing properties, the use of DeferRefresh is recommended.

In some applications, embedding the XML inline within the XAML page can be inconvenient because the exact content of the data must be known at compile time. Therefore, you can obtain the data from an external XML file, as in the following example.

<XmlDataProvider x:Key="BookData" Source="data\bookdata.xml" XPath="Books"/>

For the complete code sample, see XML Data Source with Embedded Data File Sample.

If the XML data resides in a remote XML file, you define access to the data by assigning an appropriate URL to the Source attribute as follows:

<XmlDataProvider x:Key="BookData" Source="http://MyUrl" XPath="Books"/>

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Show: