Note that there are some explanatory texts on larger screens.

plurals
  1. POtemplated label should be non-visible when content is null but border keeps showing
    text
    copied!<p>this must be very simple but it's monday morning.. I have a label and overridden the template with a border. when I set statusLabel.Content to null I expect the label to become non-visible but instead the label's border still is. how do I get rid of the border just when statusLabel.Content is null? below is the associated xaml:</p> <pre><code>&lt;StackPanel Orientation="Horizontal"&gt; &lt;Image Name="statusImage" Stretch="None" VerticalAlignment="Top" Margin="20, 20, 0, 0"/&gt; &lt;Label Name="statusLabel" Margin="20, 20, 0, 0" VerticalAlignment="Top" Background="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:StatusLayer}, Path=StatusTextBackground}" FontSize ="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:StatusLayer}, Path=FontSize}" FontStyle="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:StatusLayer}, Path=FontStyle}" FontWeight="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:StatusLayer}, Path=FontWeight}" Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:StatusLayer}, Path=StatusTextForeground}" FontFamily="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:StatusLayer}, Path=FontFamily}" &gt; &lt;Label.Template&gt; &lt;ControlTemplate TargetType="{x:Type Label}"&gt; &lt;Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true" CornerRadius="5"&gt; &lt;ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsEnabled" Value="false"&gt; &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Label.Template&gt; &lt;/Label&gt; &lt;/StackPanel&gt; </code></pre> <p><strong>UPDATE:</strong> thanks for the code in your answers, it showed me that my previous attempts to get the border to disappear failed because the trigger I tested with earlier (not listed in my question code) checked on Value="null" instead of Value="{x:Null}"... DOH! using the correct trigger with setting the visibility on the Label works perfectly.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload