Question

I am developing Windows Phone 8 application.Everything is pretty good , but i found one thing i have not handled beforehand - and now than Panorama Control behavior confuses me. Here`s simplified example of my application Hub Page (with Panorama Control):

First panorama item with a lot of buttons Second panorama item

Simplified page XAML is next :

    <phone:Panorama>
        <i:Interaction.Behaviors>
            <b:PanoramaBehaviour/>
        </i:Interaction.Behaviors>
        <phone:PanoramaItem Header="Panorama1">
            <ScrollViewer>
                <StackPanel>
                    <Button Height="72" Content="Button1" Click="Button_Click"/>
                    <Button Height="72" Content="Button2" Click="Button_Click"/>
                    <Button Height="72" Content="Button3" Click="Button_Click"/>
                    <Button Height="72" Content="Button4" Click="Button_Click"/>
                    <Button Height="72" Content="Button5" Click="Button_Click"/>
                    <Button Height="72" Content="Button6" Click="Button_Click"/>
                    <Button Height="72" Content="Button7" Click="Button_Click"/>
                    <Button Height="72" Content="Button8" Click="Button_Click"/>
                    <Button Height="72" Content="Button9" Click="Button_Click"/>
                </StackPanel>
            </ScrollViewer>
        </phone:PanoramaItem>

        <phone:PanoramaItem Header="Panorama2">
            <Grid Background="Red" Tap="GridTap"/>
        </phone:PanoramaItem>

    </phone:Panorama>

So the problem is next - often, when i try to swipe panorama from one item to another, i have one of buttons of first panorama item clicked. So i`m navigated to another application page. Can somebody tell me, how do i prevent this panorama control behavior ?

-----------------EDIT: EventToCommand solutions doesnt work for me.

Was it helpful?

Solution

Yes that one bugs me too and has been an issue since WP7. The solution is to use the Tap event in this case rather than the Click event as that doesn't give false activations in the same way. Tap is available on any UIElement, not just buttons.

OTHER TIPS

DONE!) As Paul Annetts told, tap event is raised in another way that Click event does. So for Button on Panorama control solution is next :

   xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

   <Button Content="Button1">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Tap">
                                <i:InvokeCommandAction IsEnabled="True" Command="{Binding TestCommand}"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top