locked
How to collapse the expanders dynamically in a stack panel?

    Question

  • Hello, please help me in this scenario:

    I have created 1 stack panel & dynamically i have added the expanders.

    How to collapse the expanders when 1 expander is expanded???

    i want 1 expander to be expanded at a time, when i expand 1 expander, automatically other all expanders should be in collapsed state??

    Tuesday, August 10, 2010 5:56 AM

All replies

  • You'll need to loop through them and set the IsExpanded property to false. Depending on what else is going on in the form, you can either loop through the stack panel's Children collection and check for the type, or you can keep a little array of references to the expanders you're adding at runtime and loop through that. FWIW, I'd be tempted to do the latter, but I suspect the former is probably better practice, really.
    Rebecca M. Riordan
    Tuesday, August 17, 2010 1:56 PM