RSS

WPF: Difference of Visibility.Collapsed and Visibility.Hidden

16 Sep

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.

 
1 Comment

Posted by on September 16, 2012 in Dotnet/C#

 

Tags:

One response to “WPF: Difference of Visibility.Collapsed and Visibility.Hidden

  1. silver price

    October 13, 2012 at 1:29 pm

    This tutorial uses the Dynamic Panel and the “Show Panel(s)” action to dynamically show a hidden error message.

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: