This documentation is archived and is not being maintained.

Condition.Binding Property

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

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

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  A binding declaration. See Binding Declarations Overview for more information. 

Property Value

The default value is null.

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.

In the following example, the ItemsSource of the ListBox is bound to Places, an ObservableCollection of Place objects. Place objects have properties Name and State. The definition of Place and Places are not shown but can be found in the Binding Using Data Triggers Sample.

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}}"/>

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