Take the 2-minute tour ×

i am wondering if it's possible to create styles in XAML to the events of a Control. To properties i know that is possible, but and to the Events?

What i need is to apply some styles to a ComboBox when the DropDown opens, and then apply other style after DropDown closes. Is possible to create a style in XAML to this event or any other one?

This is easy to do when he create the event in the code behind and it will do whatever we want, but i am wondering if it's possible to prevent that and simply create a Style.

And anyway it's a Style that i will apply in more than one ComboBox, and so it's why i don't want to create one event per ComboBox.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Do you really need the events? How about this:

<Style TargetType="{x:Type ComboBox}">
    <!-- Default style setters here -->
        <Trigger Property="IsDropDownOpen" Value="True">
            <!-- Opened style setters here -->
share|improve this answer
Thanks! It works –  Miguel Apr 14 '11 at 11:30
Good to hear that, i was just about to test it since you reported problems earlier. –  H.B. Apr 14 '11 at 11:44
The problem that i was doing other stuff in the ComboBox before, when i saw it, your example starts to work perfectly ;) –  Miguel Apr 14 '11 at 13:22
add comment

Your Answer


