Reputation: 41
I'm working on a "tricky" UI. Part of what I need to do is easily show and hide various UserControls. Generally one control will occupy the entire main window when needed, the other's will hide.
In WinForms I used to simply use SendToBack and BringToFront and easily showed the control I wanted to show. Now I have no clue. Played around with zorder but that didn't seem to work.
I'm thinking maybe put all the controls I want on the main window, then pro-grammatically resize them and remove the unused ones... or something.
Any ideas?
Upvotes: 2
Views: 1051
Reputation: 137118
You should set the Visibility
property to Collapsed
, Hidden
or Visbible
depending on whether you want the controls removed, hidden or shown.
As @AresAvatar points out Collapsed
removes the control completely so it takes up no space, this means that other controls may move around the container. If the position of elements is important then using Hidden
will be the better option.
UIElement.Visibility Property on MSDN
Visibility Enumeration on MSDN
Upvotes: 2