Windows apps
Collapse the table of content
Expand the table of content
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.

Style::Setters Property

 

Gets a collection of Setter and EventSetter objects.

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

public:
property SetterBaseCollection^ Setters {
	SetterBaseCollection^ get();
}

Property Value

Type: System.Windows::SetterBaseCollection^

A collection of Setter and EventSetter objects. The default is an empty collection.

The Setters property of a Style object can consist only of objects assignable to SetterBase. Adding a SetterBase child to a Style object implicitly adds it to the SetterBaseCollection for the Style object.

An explicit property element usage for Setters is also relatively common. This is a markup style decision that can sometimes help distinguish Setters from Resources and Triggers items in a complex style. For example:

<Style>
  <Style.Setters>
    <!--one or more SetterBase derived object elements here-->
  </Style.Setters>
</Style>

<object>
  oneOrMoreSetters
</object>

oneOrMoreSetters

One or more Setter or EventSetter objects.

The following example shows how to use this property.

No code example is currently available or this language may not be supported.

Adding a SetterBase child to a Style object implicitly adds it to the SetterBaseCollection for the Style object. The following EventSetter is implicitly added to the SetterBaseCollection of the style:

<StackPanel
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="SDKSample.EventOvw2"
  Name="dpanel2"
  Initialized="PrimeHandledToo"
>
  <StackPanel.Resources>
    <Style TargetType="{x:Type Button}">
      <EventSetter Event="Click" Handler="b1SetColor"/>
    </Style>
  </StackPanel.Resources>
  <Button>Click me</Button>
  <Button Name="ThisButton" Click="HandleThis">
    Raise event, handle it, use handled=true handler to get it anyway.
  </Button>
</StackPanel>

.NET Framework
Available since 3.0
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show:
© 2016 Microsoft