TextBlock
always occupies some height even if it doesn't contain any text. The height of the TextBlock
is determined by the font size if no text is present, except in case when it is explicitly set by the user, of course. Is there a way to make the TextBlock
size equal (0,0) if there is no text present (or to make it collapsed)? Thanks.
Note: I have created a converter that set's the Visibility
property of the TextBlock
to Collapsed
if there is no text, but I was wondering if the same or similar solution is possible without any converter or code-behind coding, i.e. to make it behave as explained only by using XAML.
<Style TargetType="TextBlock">
<Style.Triggers>
<Trigger Property="Text" Value="">
<Setter Property="Visibility" Value="Collapsed"/>
</Trigger>
</Style.Triggers>
</Style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With