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.
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.
But when we change the Visibility.Hidden to Visibility.Collapsed, it works like a charm!
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.