Search code examples
wpfxamlexpander

Preventing a WPF Expander from expanding when header is clicked


How can I prevent a WPF Expander from expanding when its header is clicked? I would like my Expander to expand or collapse only when the expand button itself is clicked.

I imagine the answer has something to do with canceling a bubbled event. If possible I would like to implement the solution in XAML while avoiding retemplating the entire Expander.


Solution

  • The header is the button that creates the event, so you need to change the template for your Expander to just have the expander icon as the button.

    Here is a post of how to change the expander.