Modifica

Condividi tramite


EventSetter.Event Property

Definition

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

public:
 property System::Windows::RoutedEvent ^ Event { System::Windows::RoutedEvent ^ get(); void set(System::Windows::RoutedEvent ^ value); };
public System.Windows.RoutedEvent Event { get; set; }
member this.Event : System.Windows.RoutedEvent with get, set
Public Property Event As RoutedEvent

Property Value

The identifier field of the routed event.

Exceptions

Attempted to set this property on a sealed EventSetter .

Examples

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>

Remarks

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.

Applies to

See also