Binding Property
Collapse the table of content
Expand the table of content

DataTrigger.Binding Property


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

Namespace:   System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)

<LocalizabilityAttribute(LocalizationCategory.None, Readability := Readability.Unreadable)>
Public Property Binding As BindingBase

Property Value

Type: System.Windows.Data.BindingBase

The default value is null.

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.

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

    <Binding …/>


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

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.

.NET Framework
Available since 3.0
Return to top
© 2015 Microsoft