Source property

Binding.Source property

Gets or sets the data source for the binding.


Public Property Source As Object

<Binding Source="sourceReference"/>

XAML Values


A reference to an existing object that serves as the data source. Typically the object is created in a ResourceDictionary and given a key, then referenced by using the {StaticResource} markup extension. For example: <Binding Source="{StaticResource customDataSourceObject}" .../>

Property value

Type: System.Object [.NET] | Platform::Object [C++]

The source object that contains the data for the binding.


The Source property is optional on a Binding object. If the Source property is set on a Binding object, the data source applies only to the target properties that use that Binding object.

To create a data source that is inherited by all the child elements in the tree, instead set the DataContext property on the parent element. Then the parent element and all its children look to the DataContext as the source of their bindings. If the Source is set for a child element, it will override the DataContext inheritance in that instance.

The target can bind directly to the Source object if the path is empty or to a property of the Source object as defined by the path. The path is set either in XAML with the binding syntax or when the Binding object is created.

You can't set the property values of a Binding object after that binding has been attached to a target element and target property. If you attempt this you'll get a run-time exception.


The following code example demonstrates how to set this property in XAML. For the complete code listing, see the XAML data binding sample.


    <CollectionViewSource x:Name="teamsCVS"/>

  <ListBox x:Name="lbTeams" Height="200" 
    ItemsSource="{Binding Source={StaticResource teamsCVS}}">
      <DataTemplate><!-- ... --></DataTemplate>


The following code example demonstrates how to set this property in code.

'Create the source string 
Dim s As String = "Hello"

'Create the binding description 
Dim b As New Binding()
b.Mode = BindingMode.OneTime
b.Source = s

'Attach the binding to the target 
MyText.SetBinding(TextBlock.TextProperty, b)

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


Windows::UI::Xaml::Data [C++]



Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]


Windows::UI::Xaml::Data [C++]



See also

XAML data binding sample
Data binding in depth



© 2016 Microsoft