Search code examples
windows-phone-8tap

tap event: how to set an event for first tap, and another event for second tap


I'm developing a Windows phone 8 app with visual studio.

I made two buttons, button1 and button2, and two textblocks that are under each button.

Button2 is under the button1, so button2 and textblock1 are overlaying each other.

When user clicks button1 I set textblock1.Visibility = true, and change button2's margin, so the app renders the following layout:

In the upper part there is the button1.

The textblock1 is in the middle

And the button2 is in the lowest part.

Now, when I re-tap the button1 I just want that textblock1.Visibility turns false and button2 returns to is original position. So I want to implement a species of dropdown button text, but i haven't find a way to do that.

Can anyone help me? Is there another way to to that?

I've tried a Listpicker from WPToolkit, but I don't want the selected item to be shown in the listpicker when this is not selected, and substantially I have the same tap problem.


Solution

  • I'm going to answer to the question that is in your thread title : "tap event: how to set an event for first tap, and another event for second tap".

    There is several ways, you can set up a boolean variable or increase a counter.

    In your case, you can check the visibility of your textblock1 :

    if(textblock1.Visibility == Visibility.Collapsed)
    {
        //first click
        textblock1.Visibility = Visibility.Visible;
    }
    else {
        //second click
        textblock1.Visibility = Visibility.Collapsed;
    }
    

    To the previous code you just have to add your instructions for the button2 position.

    If you want to create your own ListPicker or ComboBox, you can read this tutorial but it is in french... :)