Usher
Usher

Reputation: 2146

Re-Arranging the controls Dynamically in WPF

I have four text boxes (eg: TexBoxA, B, C and D) in Main.xaml, i set couple of text boxes (eg TexboxB and TextboxC) make it hidden based on the logic in Main.xaml.cs.

Now iam trying to re arrange the text boxes and refill the space made by TextboxB and C. so the form should look like

TextboxA
TextboxD

rather than

TextboxA
(Space-->Hidden TexboxB )
(Space-->Hidden TextboxC)
TextboxD.

Could you please suggest me, what's the best approach in WPF ?

Upvotes: 0

Views: 192

Answers (2)

vesan
vesan

Reputation: 3369

Visibility="Hidden" will indeed reserve space for the control. What you want is Visibility="Collapsed"

Of course it depends what container your textboxes are in. For StackPanel, WrapPanel, DockPanel or Grid with row height set to "Auto" this should work.

Upvotes: 2

bit
bit

Reputation: 4487

A grid with RowDefinations with Height= "Auto", should do it

Upvotes: 1

Related Questions