Binding Class


Defines a binding that connects the properties of binding targets and data sources.

Equivalent WinUI class: Microsoft.UI.Xaml.Data.Binding.

/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class Binding : BindingBase
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public class Binding : BindingBase
Public Class Binding
Inherits BindingBase
<Binding .../>
- or -
<dependencyobject dependencyproperty="{Binding bindingArgs}" />

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)


The following code example demonstrates how to create a binding in XAML. For the complete code listing, see the XAML data binding sample.

<StackPanel Margin="5">

  <TextBlock Text="Name:" Style="{StaticResource DescriptionTextStyle}" 
    Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top"/>

  <TextBox Text="{Binding Path=Name, Mode=TwoWay}" 
    Width="350" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top"/>

  <TextBlock Text="Organization:" Style="{StaticResource DescriptionTextStyle}" 
    Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top"/>

  <!-- You can omit the 'Path=' portion of the binding expression. --> 
  <TextBox Text="{Binding Organization, Mode=TwoWay}" Width="350" 
    Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top"/>


The following example code demonstrates how to create a binding in code.

// Create the source string.
string s = "Hello";

// Create the binding description.
Binding b = new Binding();
b.Mode = BindingMode.OneTime;
b.Source = s;

// Attach the binding to the target.
TextBlock MyText = new TextBlock();
MyText.SetBinding(TextBlock.TextProperty, b);
// Create the source string.
String^ s = ref new String(L"Hello");

// Create the binding description.
Binding^ b = ref new Binding();
b->Mode = BindingMode::OneTime;
b->Source = s;

// Attach the binding to the target.
TextBlock^ MyText = ref new TextBlock();
MyText->SetBinding(MyText->TextProperty, b);
'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 
Dim MyText As New TextBlock()
MyText.SetBinding(TextBlock.TextProperty, b)


The {Binding} markup extension enables you to specify a Binding value as a single attribute string in XAML, including setting Binding properties such as Path and Source. For more info about data binding concepts, see Data binding in depth.

The Binding class might be considered the code-behind exposure of the {Binding} markup extension. If a binding is already applied to a target (which happens when the XAML is loaded), you can't set the read-write properties of a Binding object to change how a binding behaves at run-time. Any XAML-defined binding should be considered immutable. But you can create a new Binding object, set its properties, and establish a new binding on a specific UI element target using FrameworkElement.SetBinding. For more info, see Creating bindings in code.

A Binding object connects a dependency property of a FrameworkElement directly to a data object so that updates to the data object are automatically propagated to the property that uses data binding. The Binding class defines the properties of a binding. Each binding must have a target element, target property, and data source, although some values are provided by default if you don't specify them.

To bind to a property or a sub-property on a data object, set the Path property of the Binding object. For more info on how to set Path in code or in XAML, see Property-path syntax or {Binding} markup extension.

You can apply an instance of a Binding class to multiple targets. However, you cannot modify the property values of a Binding object after you attach it to a target element.


Calling the FrameworkElement.SetBinding method and passing in a new Binding object won't necessarily remove an existing binding. Instead, you should use the DependencyObject.ClearValue method.

For more info on XAML attribute usage for properties that can take a Binding, or that can otherwise be set to a data-bound value, see {Binding} markup extension.

The property that is the target of a data binding must be a dependency property. For more info, see Dependency properties overview.



Initializes a new instance of the Binding class.



Gets or sets the converter object that is called by the binding engine to modify the data as it is passed between the source and target, or vice versa.

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


Gets or sets a value that names the language to pass to any converter specified by the Converter property.

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


Gets or sets a parameter that can be used in the Converter logic.

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


Gets the CoreDispatcher that this object is associated with. The CoreDispatcher represents a facility that can access the DependencyObject on the UI thread even if the code is initiated by a non-UI thread.

Equivalent WinUI property: Microsoft.UI.Xaml.DependencyObject.Dispatcher.

(Inherited from DependencyObject)

Gets or sets the name of the element to use as the binding source for the Binding.

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


Gets or sets the value to use when the binding is unable to return a value.

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


Gets or sets a value that indicates the direction of the data flow in the binding.

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


Gets or sets the path to the binding source property.

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


Gets or sets the binding source by specifying its location relative to the position of the binding target. This is most often used in bindings within XAML control templates.

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


Gets or sets the data source for the binding.

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


Gets or sets the value that is used in the target when the value of the source is null.

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


Gets or sets a value that determines the timing of binding source updates for two-way bindings.

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



Clears the local value of a dependency property.

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObject.ClearValue.

(Inherited from DependencyObject)

Returns any base value established for a dependency property, which would apply in cases where an animation is not active.

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObject.GetAnimationBaseValue.

(Inherited from DependencyObject)

Returns the current effective value of a dependency property from a DependencyObject.

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObject.GetValue.

(Inherited from DependencyObject)

Returns the local value of a dependency property, if a local value is set.

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObject.ReadLocalValue.

(Inherited from DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

Registers a notification function for listening to changes to a specific DependencyProperty on this DependencyObject instance.

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObject.RegisterPropertyChangedCallback.

(Inherited from DependencyObject)
SetValue(DependencyProperty, Object)

Sets the local value of a dependency property on a DependencyObject.

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObject.SetValue.

(Inherited from DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

Cancels a change notification that was previously registered by calling RegisterPropertyChangedCallback.

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObject.UnregisterPropertyChangedCallback.

(Inherited from DependencyObject)

Applies to

See also