Windows Phone 8图像轻弹事件无法正常工作

时间:2015-08-12 18:56:45

标签: c# wpf windows-phone-8

我在Windows手机8页的xaml中有以下代码..

  <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <StackPanel>
                    <Image Name="img" Width="350" Height="480" Margin="0,40,0,0">
                        <toolkit:GestureService.GestureListener>
                            <toolkit:GestureListener Flick="GestureListener_Flick"></toolkit:GestureListener>
                        </toolkit:GestureService.GestureListener>
                    </Image>
                </StackPanel>
            </Grid>

CS文件代码:

public void View()
        {
            Dispatcher.BeginInvoke(() =>
                {

                    pics = new List<string>();
                    pics = (List<string>)Application.Current.Resources["Photolist"];
                    img.Source = new BitmapImage(new Uri("https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=" + pics[imagenm] + "&key=AIzaSyDnoBLK2Zk46LRPb1qRQYJIVRoUvBeo5tA"));
                });
        }

        private void GestureListener_Flick(object sender, FlickGestureEventArgs e)
        {

            if (e.HorizontalVelocity > 0)
            {
                value +=imagenm;
                img.Source = new BitmapImage(new Uri("https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=" + pics[value] + "&key=AIzaSyDnoBLK2Zk46LRPb1qRQYJIVRoUvBeo5tA"));
            }
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                imagenm = Convert.ToInt32(NavigationContext.QueryString["imgname"]);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            View();
        }

现在我可以完美地显示上一个窗口中用户选择的图像。但当我轻弹时,似乎没有任何事情发生。请帮助解释图像上的轻弹事件未触发的原因。感谢。

0 个答案:

没有答案