Expanding/collapsing a WPF Expander
Asked Answered
I

2

9

How to expand/collapse a WPF Expander in code? I need to do it in order to initialize a control in it.

Izabel answered 17/1, 2012 at 8:1 Comment(1)
Don't see why you need to expand...to initialize a control in it? If that control has it's Name property set you can easily refer to it in code without expanding the expander that holds the control you want to initialize.Neutral
D
23

Use the IsExpanded property, set it to true for making the content visible:

myExpander.IsExpanded = true;

Set it to false to collapse the expander.

Deteriorate answered 17/1, 2012 at 8:5 Comment(0)
E
0

You could just set IsExpanded property, but I prefer to use VisualStateManager and do such UI changes using VisualStateManager.GoToState.

Electrophoresis answered 17/1, 2012 at 8:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.