Difference between Visibility.Collapsed and Visibility.Hidden

Sauron picture Sauron · May 20, 2009 · Viewed 130.2k times · Source

What are differences between Visibility.Collapsed and Visibility.Hidden in WPF?

Answer

Razzie picture Razzie · May 20, 2009

The difference is that Visibility.Hidden hides the control, but reserves the space it occupies in the layout. So it renders whitespace instead of the control. Visibilty.Collapsed does not render the control and does not reserve the whitespace. The space the control would take is 'collapsed', hence the name.

The exact text from the MSDN:

Collapsed: Do not display the element, and do not reserve space for it in layout.

Hidden: Do not display the element, but reserve space for the element in layout.

Visible: Display the element.

See: http://msdn.microsoft.com/en-us/library/system.windows.visibility.aspx