我按照这篇文章的说明成功地实现了flick
(又名slide
,swipe
)手势,但由于某种原因,它只能在屏幕的上半部分被识别。Windows 8 Phone App
我在模拟器和实际的开发设备(Nokia Lumia 520
)上进行了尝试,得到了相同的结果。
我的应用程序正在使用ApplicationBar并且轻弹手势巧合地开始识别ApplicationBar天桥结束的动作(完全扩展)。
侦听手势的图像也有一个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>