How to hide Label or TextBlock inside a WPF Grid

31,715

Solution 1

Never mind, it does work when you run it, it was just the designer that does not display it correctly.

Solution 2

In Code you can use something like the following:

Label1.Visibility = Visibility.Hidden;

Solution 3

Try Visibility.Collapsed

<TextBlock Visibility="Collapsed">

Solution 4

@Laxman Singhare you sure about Visibility.Hidden? It should be

this.TextBlock.Visibility = Visibility.Collapsed; 
Share:
31,715
Admin
Author by

Admin

Updated on July 19, 2022

Comments

  • Admin
    Admin almost 2 years

    I am trying to hide the TextBlock and Label which are placed inside a grid like so:

    <TextBlock Grid.Column="3" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Hidden">Text inside TextBlock</TextBlock>
    <Label Grid.Column="4" Grid.Row="2" HorizontalAlignment="Center" Visibility="Hidden">Text inside Label</Label>
    

    But the text does not disappear. Any ideas why that is?

    • Admin
      Admin about 15 years
      UPDATE: Damn, it does work when you run it, it was just the designer that does not display it correctly.
  • fedeteka
    fedeteka about 6 years
    Working solution!