简体   繁体   中英

WP8: Button events triggering when navigating in panorama/pivot

I'm currently devloping an App for WP8 and am having a Problem when navigating Panorama or Pivot-Views.

For example: I have a Panorama which itself contains a few Buttons on every Page. If I try to navigate between those Pages, I sometimes accidentally manage to Raise a Click-Event for some Buttons.

After trying to reproduce the bug, I found out, that this mainly happens when I swipe over a short distance. If I swipe long distance, the bug doesn't appear and no event is raised.

I am using Command Binding for Eventhandling, should I maybe change this? I'm really trying to figure this out, but I still can't find a way other than a Service which disables all Events if a swipe occurs.

Thanks in advance for any Help you can give me!

PS: Here is some code, don't know if/how it might help:

<phone:Panorama x:Name="Panorama" Title="{Binding LocalizationService.Resources.ApplicationTitle}">
    <phone:PanoramaItem Header="{Binding LocalizationService.Resources.MainPage_Header}" HeaderTemplate="{StaticResource PanoramaItemHeaderTemplate}">

    ...

      <Button Command="{Binding CmdNavigateToZipSearch}" Style="{StaticResource PizzaButtonAccentStyle}" Width="214" Height="172">
          <Grid>
             <Grid.RowDefinitions>
                 <RowDefinition Height="*" />
                 <RowDefinition Height="Auto" />
             </Grid.RowDefinitions>
             <Image Grid.Row="0" Source="/Assets/icon_plz-suche.png" Stretch="Uniform" Height="77" Margin="1,6,0,0" />
             <TextBlock Grid.Row="1" Text="{Binding LocalizationService.Resources.MainPage_ZipSearch_Label}" Style="{StaticResource PizzaTextContrastStyle}" />
         </Grid>
     </Button>

    ...

Internally (AFAIK) the command on a button is fired based on a click event. Instead of using the click/command event use an EventToCommand solution to bind your command to the Tap event as this cannot be fired at the same time as a swipe due to it's threshold of movement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM