locked
Simple C# question RRS feed

  • Question

  • I recently built a calculator in C# for the Windows 8 App store, submitted it and got it approved and its in there now! But it was a very rushed and unfinished product, I was more or less excited that I had a working app so I submitted. Now I'm trying to make it do more, the first version only did addition, the pending certification version adds subtration and multiplication, the version I'm working on now for the next big release will have themes.
    Here is what I'm trying to do now. I have a simple calc with large buttons great for a full screen touch display, I'd like to be able to group buttons together and change the visibility of the group with the press of a button, its for a theme thing I'm working on.

    Group A (button a, button b, button c,)
    Press button Z and Group A visibility collapses.

    In Visual Studio I grouped the buttons in a grid called gridTest and added a button and on the button click event is listed below.

    1. private void Button_Click(object sender, RoutedEventArgs e)
    2. {
    3. gridTest.Visibility="Collapsed";
    4. }

    But that doesn't work and I can't figure it out.

    Saturday, January 18, 2014 7:41 PM

Answers

  • Hello ontulmora,

    To collapse "gridTest" from C# code, you have to use the Visibility enum instead of the string "Collapsed". Your button click event should be :

    private void Button_Click(object sender, RoutedEventArgs e)
    {
         gridTest.Visibility = Visibility.Collapsed;
    }

    • Marked as answer by ontulmora Sunday, January 19, 2014 2:48 AM
    Saturday, January 18, 2014 11:38 PM

All replies

  • Hello ontulmora,

    To collapse "gridTest" from C# code, you have to use the Visibility enum instead of the string "Collapsed". Your button click event should be :

    private void Button_Click(object sender, RoutedEventArgs e)
    {
         gridTest.Visibility = Visibility.Collapsed;
    }

    • Marked as answer by ontulmora Sunday, January 19, 2014 2:48 AM
    Saturday, January 18, 2014 11:38 PM
  • That was exactly what I was looking for. Thanks!

    Sunday, January 19, 2014 2:48 AM
  • I did not notice but how could you compile it?

    -- Vishal Kaushik --

    Please 'Mark as Answer' if my post answers your question and 'Vote as Helpful' if it helps you. Happy Coding!!!

    Sunday, January 19, 2014 3:55 AM