hiding a label
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: hiding a label

  1. #1
    Join Date
    Apr 2009
    Posts
    12

    hiding a label

    I am trying to hide a label based on its value = N/A as passed into the tag. Does not seem to work any advice?

    <Grid>
    <Grid.Resources>

    <Style TargetType="{x:Type Label}" x:Key="LabelTextStyle">
    <Style.Triggers>
    <Trigger Property="Tag" Value="N/A">
    <Setter Property="Visibility" Value="Hidden"/>
    <Setter Property="Background" Value="Blue"/>
    <Setter Property="FontFamily" Value="Trebuchet MS"/>
    <Setter Property="FontSize" Value="18"/>
    </Trigger>
    </Style.Triggers>
    </Style>
    </Grid.Resources>

    <Label Style="{StaticResource LabelTextStyle}" FontSize="14" Tag="{Binding Path=lblCOO}" FontWeight="Bold" Foreground="#FFF9F7F7" Margin="23,9,59,36" Name="lblCOO" Grid.Column="3" Grid.Row="1"></Label>
    </Grid>

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,485

    Re: hiding a label

    Try to determine whether it's the trigger that is failing or the value getting passed in.

    You can do this by [temporarily] hardcoding the Tag value. In other words, rather than
    Code:
    Tag="{Binding Path=lblCOO}"
    hardcode
    Code:
    Tag="N/A"
    .

    If this works, then look at the value getting passed in; if not then look at the trigger (style) code.

  3. #3
    Join Date
    Apr 2009
    Posts
    12

    Re: hiding a label

    I had to use Tag="{Binding ElementName=lblCOO, Path=Content}"

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,485

    Re: hiding a label

    Quote Originally Posted by neo_xaml View Post
    I had to use Tag="{Binding ElementName=lblCOO, Path=Content}"
    Ah, I assumed that you were binding to a business object, not another UI element.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center