首页 文章

在wp7中处理手势点击事件

提问于
浏览
0

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

我的代码是

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 回答

  • 1

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

    • 一次在设计师中,和

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

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

相关问题