I have styled a window to replace the standard Chrome and I want to handle the Activated and Deactivated events using EventSetters. I get an error "...'Activated' must be a RoutedEvent registered..." with this:
<EventSetter Event="Activated" Handler="Window_Activated"/>
However, this works fine in the same style.
<EventSetter Event="Loaded" Handler="Window_Loaded"/>
Anyone run across this or know what's up?
Edit:
<Style x:Key="Window_Cartesia" TargetType="{x:Type Window}">
<Setter Property="WindowStyle" Value="None"/>
<Setter Property="AllowsTransparency" Value="True"/>
<Setter Property="Background" Value="Transparent"/>
<EventSetter Event="Loaded" Handler="Loaded"/>
<EventSetter Event="Activated" Handler="Window_Activated"/>
<EventSetter Event="KeyDown" Handler="KeyDown"/>
...
EDIT:
This seems to cover it.
Defined in the Loaded event:
AddHandler Win.Activated, AddressOf Activated
AddHandler Win.Deactivated, AddressOf Deactivated
Because this is code behind for a style, I need an instance reference which is Win. I don't know if this is the best way to accomplish this but...
EDIT 1:
Alternatively, a trigger for IsActive to handle it in xaml.
<Trigger Property="IsActive" Value="True">
...
</Trigger>