Dante
Dante

Reputation: 3891

Windows Phone app button requires two presses to fire its action

I have a button inside of a stackpanel that has to be pressed twice to execute its action. This only happens when I hide the stackpanel and show it again.

First, I press the button and the stackpanel is hidden, hiding the button. I press another button that brings the stackpanel back. I click the button, doesn't work. Click again, and it works.

This happens in the emulator and in the phone.

This is the xaml I have:

<StackPanel Grid.Row="1" Name="myPanel">
      <Button Content="{Binding LocalizedResources.ButtonX, Source={StaticResource Localization}}" Name="btnX" Click="btnX_Click" />
</StackPanel>

In the code, I just control the visibility as shown below:

myPanel.Visibility = Visibility.Collapsed;

Any ideas?

Upvotes: 1

Views: 77

Answers (1)

MoonKnight
MoonKnight

Reputation: 23831

Give the stack panel Focus upon return to the page. The double click comes from the fact that the first click is giving the control Focus the second is then allowing your embedded control to be activated.

I hope this helps.

Upvotes: 2

Related Questions