在wp7中处理手势点击事件

时间:2012-11-10 05:01:06

标签: c# .net silverlight windows-phone-7 gesture

我有点混淆如何处理手势点击事件? 当我点击我的手机屏幕时,手势点击事件会自动触发两次。但我只想要一次

我的代码是

    var g1 = GestureService.GetGestureListener(TransactionList);
                g1.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(g1_Tap);
   g1.Hold += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(g1_Hold);



        void g1_Hold(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
        {
            throw new NotImplementedException();
        }     
        void g1_Tap(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
            {
                ListBox hi = (ListBox)sender;
                ClsGetNewCampaign cg = (ClsGetNewCampaign)hi.SelectedItem;
                ClsGetNewCampaign.setlst(cg.cmpLoutAry);


                //int campaignId = Convert.ToInt32(cg.CampaignID);
                string campaignID = cg.CampaignID;
                string campaignName = cg.CampainNAME;
                string campaignImage = cg.CampainIMGPATH;
                string layoutTitle = cg.LayoutTitle;
                string layoutId = cg.LayoutID;


                //_ClsDatabase.Add_Data(campaignId, campaignName, campaignImage, layoutTitle, layoutId);

                string param = tbNew1.Text;
                NavigationService.Navigate(new Uri(string.Format("/VodafoneARview/Advertisement.xaml?parameter0={0},parameter1={1},parameter2={2},parameter3={3},parameter4={4},parameter5={5}", param,campaignID,campaignName,campaignImage,layoutTitle,layoutId), UriKind.RelativeOrAbsolute));


            }

1 个答案:

答案 0 :(得分:1)

正如我在你的回答评论中提到的那样,确保你没有意外地添加了两次事件处理程序:

  • 曾在设计师中,
  • 在您的代码中,g1.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(g1_Tap);

这可以解释为什么事件发射两次:)