Quantcast
Channel: Programming – Xinyustudio
Viewing all articles
Browse latest Browse all 284

WPF: Difference of Visibility.Collapsed and Visibility.Hidden

$
0
0

In a recent trial to rename a TreeViewItem in WPF, I added a TextBlock as well as a Hidden TextBox in the Header, so that when in a “rename”, I will toggle of the TextBlock and TextBox’s visibility and allows for the editing vs static text.

image

It seems fine, right? And running this project, you will notice that it is not exactly what we want. Although the TextBlock/TextBox is hidden, yet the rectangle region it occupies still shows up.

image image
Visibility.Hidden

But when we change the Visibility.Hidden to Visibility.Collapsed, it works like a charm!

image image
Visibility.Collapsed

To recap, the collapsed is more than hidden, and try to use it in replacement of the hidden attribute if you just entered the WPF from Winform.


Filed under: Dotnet/C# Tagged: WPF Difference Visibility.Collapsed Visibility.Hidden

Viewing all articles
Browse latest Browse all 284

Trending Articles