What are the differences between Visibility.Hidden and Visibility.Collapsed?

2

What are the differences between WPF visibility% wp% and wpf%?

There are practical or theoretical differences between set the Visibility.Hidden and Visibility.Collapsed of a control for zero and set its visibility to Height or Width ? If yes, what would be the differences for each of the two modes?

    
asked by anonymous 10.09.2016 / 03:41

2 answers

4

Obviously both prevent the element from being viewed.

Visibility.Hidden reserves the space that the element will occupy in layout , so nothing will be redrawn except in that area. Everything is fixed in place, hiding or not. It just hides, but the element is there.

Visibility.Collapsed does not reserve the space and layout , and may require redesigning other elements to adjust positions. It will set height and length to zero and the element will no longer be there.

If you only change the width and height the element will change the layout , equal to Collapsed , but the element remains present, equal to Hidden , even if invisible, keeping characteristics of something available, active. For example, it may gain focus when controls are changing elements in navigation, most likely with TAB . There may be other consequences. Unless you just want to get the element off the screen, taking its space, but remain there, it is wrong to use that technique.

Documentation .

    
10.09.2016 / 04:07
2

Visibility.Hidden makes the object invisible but reserves its space in the layout.

Visibility.Collapsed makes the object invisible and does not occupy any space in the layout.

Since setting Width or Height to zero I do not see much sense since this would only make it harder to hide and show the element, because to display again I would need to know the size this element should have, the cases in which you do not use Width and Height to define the size of the elements.

    
10.09.2016 / 04:02