.NET Framework Class Library
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)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Syntax

Visual Basic (Declaration)
Public Property Source As Uri
Visual Basic (Usage)
Dim instance As XmlDataProvider
Dim value As Uri

value = instance.Source

instance.Source = value
C#
public Uri Source { get; set; }
Visual C++
public:
property Uri^ Source {
    Uri^ get ();
    void set (Uri^ value);
}
JScript
public function get Source () : Uri
public function set Source (value : Uri)
XAML Attribute Usage
<object Source="Uri" .../>

Property Value

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

XmlDataProvider exposes the following ways to access XML data.

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.

Examples

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.

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

For the complete code sample, see XMLDataProvider 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"/>
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0
See Also

Reference

Other Resources

Tags :


Page view tracker