EventSetter.Event 屬性

定義

取得或設定這個 EventSetter 回應的特定路由事件。

C#
public System.Windows.RoutedEvent Event { get; set; }

屬性值

路由事件的識別項欄位。

例外狀況

嘗試在密封的 EventSetter 上設定這個屬性。

範例

下列範例會在標記樣式中將 Event 屬性設定為 的 EventSetter 一部分。

XAML
<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>

備註

一旦包含 EventSetter 的樣式正在使用中,因此密封,就無法設定此屬性。 如果您在程式碼中設定此屬性,而且可能正在使用樣式,請在嘗試設定 Event 之前,先檢查 實例上的 EventSetter 屬性值 IsSealed

適用於

產品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

另請參閱