DataTrigger.Binding Property


Gets or sets the binding that produces the property value of the data object.

 property System::Windows::Data::BindingBase ^ Binding { System::Windows::Data::BindingBase ^ get(); void set(System::Windows::Data::BindingBase ^ value); };
[System.Windows.Localizability(System.Windows.LocalizationCategory.None, Readability=System.Windows.Readability.Unreadable)]
public System.Windows.Data.BindingBase Binding { get; set; }
[<System.Windows.Localizability(System.Windows.LocalizationCategory.None, Readability=System.Windows.Readability.Unreadable)>]
member this.Binding : System.Windows.Data.BindingBase with get, set
Public Property Binding As BindingBase

Property Value


The default value is null.



In the following example, the DataTrigger sets the BorderBrush of the element named border to Yellow if the TaskType property is TaskType.Home.

<DataTemplate x:Key="myTaskTemplate">
  <DataTrigger Binding="{Binding Path=TaskType}">
    <Setter TargetName="border" Property="BorderBrush" Value="Yellow"/>

For a detailed discussion of this example, see Data Templating Overview.


The property value produced by this binding is compared with the value specified by the Value property. That value is first converted to the type of the value of the binding (if possible), and then the two values are compared using the Object.Equals method. If the two values are equal, then the associated actions or setters are applied.

You create a binding and use the Path property to bind to a property of a certain object (the binding source object). For example, you may bind to the Priority property of a Task. For more information, see Data Binding Overview.

Note that you must specify both the Binding and Value properties on a DataTrigger for the data trigger to be meaningful. If one or both of the properties are not set, an exception is thrown.

XAML Attribute Usage

<object property="{Binding  declaration}"/>  

XAML Property Element Usage

    <Binding …/>  

XAML Values

Zero or more attribute-assignment clauses separated by commas (,). See Binding Markup Extension for more information.

Applies to

See also