Specifically I want all PasswordBox's using a Style to have the same static KeyDown event handler - would it be pos开发者_如何学JAVAsible to somehow set this in the Style they are using rather than setting it on each PasswordBox? (which I am having to do in code behind at the moment as they all point to the same static handler)..
EventSetter
is your friend. As for the handler - just put it into code-behind (you can create a code-behind for a resource dictionary too - just crate a CS file with the same name as the dictionary and add the class attribute to the resource dictionary XAML).
Small example:
<Style>
<EventSetter Event="KeyDown" Handler="KeyDownHandler"/>
</Style>
精彩评论