EventSetter.Event 屬性
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定這個 EventSetter 回應的特定路由事件。
public:
property System::Windows::RoutedEvent ^ Event { System::Windows::RoutedEvent ^ get(); void set(System::Windows::RoutedEvent ^ value); };
C#
public System.Windows.RoutedEvent Event { get; set; }
member this.Event : System.Windows.RoutedEvent with get, set
Public Property Event As RoutedEvent
路由事件的識別項欄位。
嘗試在密封的 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 |