Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
This topic has not yet been rated - Rate this topic

DataTrigger.Setters Property

Gets a collection of Setter objects, which describe the property values to apply when the data item meets the specified condition.

Namespace: System.Windows
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public SetterBaseCollection Setters { get; }
/** @property */
public SetterBaseCollection get_Setters ()

public function get Setters () : SetterBaseCollection

<object>
  <object.Setters>
    ZeroOrMoreSetters
  </object.Setters>
</object>
 ZeroOrMoreSetters  Zero or more Setter objects. 

Property Value

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

The following example shows two DataTrigger objects that are defined in a DataTemplate. The DataTemplate is applied to AuctionItem data objects (not shown in this example), which have the property SpecialFeatures.

The first DataTrigger is specified such that if the data object has a SpecialFeatures value of Color, then the item is displayed with a DodgerBlue background with Navy titles. If the data object has a SpecialFeatures value of Highlight, then the second DataTrigger will be active, causing the item to be displayed with an Orange border with a star.

For the complete sample, see Data Binding Demo.

<DataTemplate.Triggers>
    <DataTrigger Binding="{Binding Path=SpecialFeatures}">
        <DataTrigger.Value>
            <src:SpecialFeatures>Color</src:SpecialFeatures>
        </DataTrigger.Value>
      <DataTrigger.Setters>
        <Setter Property="BorderBrush" Value="DodgerBlue" TargetName="border" />
        <Setter Property="Foreground" Value="Navy" TargetName="descriptionTitle" />
        <Setter Property="Foreground" Value="Navy" TargetName="currentPriceTitle" />
        <Setter Property="BorderThickness" Value="3" TargetName="border" />
        <Setter Property="Padding" Value="5" TargetName="border" />
      </DataTrigger.Setters>
    </DataTrigger>
    <DataTrigger Binding="{Binding Path=SpecialFeatures}">
        <DataTrigger.Value>
            <src:SpecialFeatures>Highlight</src:SpecialFeatures>
        </DataTrigger.Value>
        <Setter Property="BorderBrush" Value="Orange" TargetName="border" />
        <Setter Property="Foreground" Value="Navy" TargetName="descriptionTitle" />
        <Setter Property="Foreground" Value="Navy" TargetName="currentPriceTitle" />
        <Setter Property="Visibility" Value="Visible" TargetName="star" />
        <Setter Property="BorderThickness" Value="3" TargetName="border" />
        <Setter Property="Padding" Value="5" TargetName="border" />
    </DataTrigger>
</DataTemplate.Triggers>

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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.