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));


            }
4

1 回答 1

1

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

  • 曾经在设计师中,并且
  • 一旦在你的代码中,就行了g1.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(g1_Tap);

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

于 2012-11-10T12:37:20.060 回答