I have a style for a ListBox. In the listbox style I have a style for the ListBoxItems. All of this is in the section.
I want to catch the IsEnabledChanged event for the Listbox Items (see this question for why). I tried setting up an EventSetter, but it can't see the event because it is not a "routed event".
How can I attach an event to this templated item? (Remember it is not attached to a specific Listbox per-se. It is a style in
Here is some sample code to show what I am talking about.
<Style x:Key="CheckBoxListStyle" TargetType="ListBox">
<Style.Resources>
<Style TargetType="ListBoxItem">
<EventSetter Event="IsEnabledChanged" Handler="OnEnabledChanged"\>
.... ^
|
This is not allowed ------
It can't find this event. Trying to get more specific (ListBoxItem.IsEnabledChanged) does not help.
Edit: I am not set on doing this in the XAML. If there is some other way to do this via the code behind that would be just as good. I just don't know how to get access to the resources templates from code behind.