Binding.Source Property


Gets or sets the data source for the binding.

Equivalent WinUI property: Microsoft.UI.Xaml.Data.Binding.Source.

 property Platform::Object ^ Source { Platform::Object ^ get(); void set(Platform::Object ^ value); };
IInspectable Source();

void Source(IInspectable value);
public object Source { get; set; }
var object = binding.source;
binding.source = object;
Public Property Source As Object
<Binding Source="sourceReference"/>

Property Value


The source object that contains the data for the binding.


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>


For an example demonstrates how to set this property in code, see the Binding class.


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.

Applies to

See also