Condition.Binding Property


Gets or sets the binding that specifies the property of the condition. This is only applicable to MultiDataTrigger objects.

 property System::Windows::Data::BindingBase ^ Binding { System::Windows::Data::BindingBase ^ get(); void set(System::Windows::Data::BindingBase ^ value); };
public System.Windows.Data.BindingBase Binding { get; set; }
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 ItemsSource of the ListBox is bound to Places, an ObservableCollection<T> of Place objects. Place objects have properties Name and State.

Each ListBoxItem of the ListBox displays a Place object. The Style in the example is applied to each ListBoxItem. The Conditions of the MultiDataTrigger are specified such that if the Name and State of the Place data item is "Portland" and "OR" respectively, then the background of corresponding ListBoxItem is set to Cyan.

  <c:Places x:Key="PlacesData"/>

  <Style TargetType="ListBoxItem">
      <DataTrigger Binding="{Binding Path=State}" Value="WA">
        <Setter Property="Foreground" Value="Red" />
          <Condition Binding="{Binding Path=Name}" Value="Portland" />
          <Condition Binding="{Binding Path=State}" Value="OR" />
        <Setter Property="Background" Value="Cyan" />

  <DataTemplate DataType="{x:Type c:Place}">
    <Canvas Width="160" Height="20">
      <TextBlock FontSize="12"
             Width="130" Canvas.Left="0" Text="{Binding Path=Name}"/>
      <TextBlock FontSize="12" Width="30"
                 Canvas.Left="130" Text="{Binding Path=State}"/>

  <TextBlock FontSize="18" Margin="5" FontWeight="Bold"
    HorizontalAlignment="Center">Data Trigger Sample</TextBlock>
  <ListBox Width="180" HorizontalAlignment="Center" Background="Honeydew"
    ItemsSource="{Binding Source={StaticResource PlacesData}}"/>


MultiDataTriggers allow you to set property values based on values of the data that is returned. For example, if you are displaying a list of task items, you may want to display a task with a red background if it is of high priority and has not been looked at for more than two weeks.

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 if it is a condition for a MultiDataTrigger, the Binding and Value properties must be set. Setting the Property value would cause an exception in that case.

XAML Attribute Usage

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

XAML Property Element Usage

    <Binding …/>  

XAML Values

A binding declaration. See Binding Declarations Overview for more information.

Applies to

See also