EventSetter is your friend. As for the handler - just put it in the encoding (you can also create code for the resource dictionary) - just collect the CS file with the same name as the dictionary and add the class attribute to the XAML resource dictionary).
A small example:
<Style> <EventSetter Event="KeyDown" Handler="KeyDownHandler"/> </Style>
Jefim source share