为什么Windows 8 Phone Flick Gesture只在屏幕的上半部分工作



按照这篇文章中的说明,我成功地在Windows 8 Phone App上实现了flick(又名slideswipe)手势,但由于某种原因,它仅在屏幕上半部分被识别。

我用模拟器和实际的开发设备(Nokia Lumia 520)尝试了这个,并得到了相同的结果。

我的应用程序正在使用应用程序栏,轻拂手势巧合地开始识别应用程序栏天桥结束的运动(在完全扩展时)。

侦听手势的图像也具有tap事件,并且该事件在整个图像(屏幕的上半部分/下半部分)中工作正常。

提前感谢...

编辑:这是我通过创建一个空白页面但仍然没有任何运气来尝试的一些代码。识别"FLICK"手势的区域被限制在手机屏幕的左上角(在模拟器和实际设备中)。

这是我的代码(CS):

FlickTest.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
namespace Windows_8_Phone_App
{
    public partial class FlickTest : PhoneApplicationPage
    {
        public FlickTest()
        {
            InitializeComponent();
        }
        private void image_GestureListener_Flick(object sender, FlickGestureEventArgs e)
        {
            if (titulo.Text == "Foo")
            {
                titulo.Text = "Bar";            
            }
            else {
                titulo.Text = "Foo";
            }
        }
    } 
}

和 XAML 代码:

   <phone:PhoneApplicationPage
    x:Class="Windows_8_Phone_App.FlickTest"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"          
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Landscape" Orientation="Landscape"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True">
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="titulo" Text="page name" Margin="9,-7,0,0" />
        </StackPanel>
        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Image x:Name="imagen" HorizontalAlignment="Left" Height="309" Margin="10,0,0,0" VerticalAlignment="Top" Width="694" Source="/Assets/AppBar/basecircle.png" Stretch="Fill">
                <toolkit:GestureService.GestureListener>
                    <toolkit:GestureListener Flick="image_GestureListener_Flick" />
                </toolkit:GestureService.GestureListener>
            </Image>
        </Grid>
    </Grid>
</phone:PhoneApplicationPage>

经过很多痛苦,问题是Windows Phone Toolkit有一个已知问题,并且在横向模式下无法正常工作(请参阅此条目)。

所以与此同时,虽然这个问题得到了解决,但我正在寻找替代方案......

刚遇到这个问题。GestureListener在横向模式下不起作用(正如alejandrormz所写)。:(

但是,我有一个解决方案->内置的操作和手势事件。 :)它易于实施。最佳示例代码:GitHub

希望这有帮助。

最新更新