Cannot get EventSetter to work
If my understanding is correct you use EventSetters to assign handlers to events in Styles. I cannot get an event setter to work.
<
StyleTargetType="{x:Type Button}"><
EventSetterEvent="Click"Handler="ButtonClickEventHandler"></EventSetter></
Style>This will not compile. It says 'The Handler attribute is not declared', although if I access the EventSetter object from c# it clearly has a 'Handler' property. How can you assign handlers to events in a style?
-Ryan
[1781 byte] By [
RyanF] at [2007-12-21]
I not able to test now but why don't you try this:
<Style TargetType="{x:Type Button}">
<EventSetter Event="Click"></EventSetter>
</Style>
My 3rd party opinion is that it doesn't answer/resolve your question.
You could just reference the same handler in every button declaration
<Button Click="ButtonClickEventHandler" </Button>
but I'm guessing that the reasons you're using a style is to avoid that.
NIK
I have code exactly like your original sample that both compiles and works as expected.
It may have somthing to do with the location of your style declaration.
NIK