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)
XML Namespace:

[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)] 
public BindingBase Binding { get; set; }
/** @property */
public BindingBase get_Binding ()

/** @property */
public void set_Binding (BindingBase value)

public function get Binding () : BindingBase

public function set Binding (value : BindingBase)

    <Binding …/>
<object property="{Binding declaration}"/>
 declaration  Zero or more attribute-assignment clauses separated by commas (,). See Binding Markup Extension for more information. 

Property Value

The default value is a null reference (Nothing in Visual Basic).

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.

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.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions