tags:

views:

346

answers:

1

Let's say I have a simple layout like this:

<StackPanel>
  <TextBlock Text="{Binding Path=Title}" />
  <TextBlock Text="{Binding Path=ShortDescription}" />
  <TextBlock Text="{Binding Path=LongDescription}" />
</StackPanel>

Now when I have ShortDescription set to null or empty string there's still a gap in place of second TextBlock. Is there some property to prevent an empty textblock from occupying space? Or should I use some other control?

Thanks.

+8  A: 

You want to set the visibility of the textbox to "Collapsed".

Visibility can be either:
Visible - Self explanatory
Hidden - Invisible but still takes up space
Collapsed - Invisible and takes up no space

Edit: You should probably set up a trigger, like so:

<Trigger Property="Text" Value="{x:Null}">
    <Setter Property="Visibility" Value="Collapsed"/>
</Trigger>
DavidN