10

I checked the stackpanel class here http://msdn.microsoft.com/en-us/library/system.windows.controls.stackpanel.aspx and it has no click event.

I'm working on a windows phone 8 app and I've got a textbox and some buttons on a stack panel. I want to include a feature where the stackpanel can be clicked then the visibility of the controls on it are set to collapsed, and then when clicked again they become visible.

How do I do this?

Nii Laryea
  • 1,211
  • 5
  • 18
  • 31

5 Answers5

10

Try using the MouseLeftButtonUp event.

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
9

You could just wrap the whole stackpanel in a button:

<button>
    <stackpanel>
    </stackpanel>
</button>

Then attach a click event or command to the button as you see fit.

Albert Bori
  • 9,832
  • 10
  • 51
  • 78
Jon B
  • 875
  • 7
  • 18
1

put the StackPanel inside the Border control, use MouseLeftButtonUp of the Border to handle event and set background of the Border to #000001

Tommy
  • 135
  • 7
0

You could probably use the TouchUp and TouchDown event. But I think you have to check if the TouchDown is on the same StackPanel as the TouchUp. So you can check if it was a "click".

Jan Peter
  • 912
  • 7
  • 19
0

You can solve this problem in a little tricky manner, if it is good then it's ok otherwise i'll Post the another one.

 <StackPanel Background="Red" MinHeight="80"  VerticalAlignment="Top" Tap="StackPanel_Tap_1" Orientation="Horizontal">
            <Button x:Name="btn1" Content="Button"/>
            <Button x:Name="btn2" Content="Button"/>
            <TextBox Height="72" x:Name="textbox1" TextWrapping="Wrap" Text="TextBox" Width="456"/>
        </StackPanel> 




 private void StackPanel_Tap_1(object sender, GestureEventArgs e)
    {


        if (btn1.IsEnabled==false)
        {
            btn1.IsEnabled = true;
            btn1.Visibility = Visibility.Visible;
            btn2.Visibility = Visibility.Visible;
            textbox1.Visibility = Visibility.Visible;
        }
        else
        {

            btn1.IsEnabled = false;
            btn1.Visibility = Visibility.Collapsed;
            btn2.Visibility = Visibility.Collapsed;
            textbox1.Visibility = Visibility.Collapsed;
        }

    }