There are of course a lot of ways to collapse a XAML TextBlock, but here is one using a style.

<TextBlock Text="{Binding Path=DescriptiveText}">
	<TextBlock.Style>
		<Style TargetType="TextBlock">
			<Style.Triggers>
				<Trigger Property="Text" Value="{x:Null}">
					<Setter Property="Visibility" Value="Collapsed" />
				</Trigger>
				<Trigger Property="Text" Value="">
					<Setter Property="Visibility" Value="Collapsed" />
				</Trigger>
			</Style.Triggers>
		</Style>
	</TextBlock.Style>
</TextBlock>

As always, feel free to comment, or ask.


Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading