EventSetter.Event Property

Gets or sets the particular routed event that this EventSetter responds to.

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

member Event : RoutedEvent with get, set
<object Event="RoutedEvent" .../>

Property Value

Type: System.Windows.RoutedEvent
The identifier field of the routed event.

ExceptionCondition
InvalidOperationException

Attempted to set this property on a sealed EventSetter .

You cannot set this property once the style containing the EventSetter is in use and thus is sealed. If you set this property in code and there is the possibility that the style is in use, check the value of the IsSealed property on the EventSetter instance before you attempt to set Event.

The following example sets the Event property as part of an EventSetter in a markup 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

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft