tags:

views:

43

answers:

1

hi everyone. i wanna ask second button_click event. i have grid on a window. when i click the button, i wanna grid to be visible and when i second clicked the button.i wanna grid to be hidden. like windows start menu. my codes are as follows. thanks in advance.

    private void Topics_Click(object sender, RoutedEventArgs e)
    {

        TGrid.Visibility = Visibility.Hidden;
    }
+1  A: 

Why don't you just use the current visibility to determine whether to hide or show it?

private void Topics_Click(object sender, RoutedEventArgs e)
{

    TGrid.Visibility = TGrid.Visibility == Visibility.Hidden 
         ? Visibility.Visible : Visibility.Hidden;
}
Jon Skeet
thank you very much. why didnt i think like that?:)
lilly