Muokkaa

Jaa


DataTrigger.Binding Property

Definition

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

public:
 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.

Attributes

Examples

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">
<DataTemplate.Triggers>
  <DataTrigger Binding="{Binding Path=TaskType}">
    <DataTrigger.Value>
      <local:TaskType>Home</local:TaskType>
    </DataTrigger.Value>
    <Setter TargetName="border" Property="BorderBrush" Value="Yellow"/>
  </DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>

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

Remarks

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

<object>  
  <object.Binding>  
    <Binding …/>  
  </object.Binding>  
</object>  

XAML Values

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

Applies to

See also