EventSetter.Event 屬性

定義

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

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

屬性值

路由事件的識別項欄位。

例外狀況

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

範例

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

<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

適用於

另請參閱