简体   繁体   English

处理WP7中的手势轻按事件

[英]Handle gesture tap event in wp7

I am little confuse how to handle gesture tap event? 我有点困惑如何处理手势点击事件? When i tap my phone screen at that time gesture tap event fire two time automatically.But i want just one time 那时我点击手机屏幕会自动触发两次手势点击事件,但是我只想一次

my code is 我的代码是

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


            }

As I mentioned in the comment on your answer, make sure that you haven't accidentally added the event handler twice: 正如我在对答案的评论中提到的那样,请确保您没有两次意外添加事件处理程序:

  • once in the designer, and 一旦进入设计器,并且
  • once in your code, on the line g1.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(g1_Tap); 在代码中,一次在g1.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(g1_Tap);行上g1.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(g1_Tap);

That would explain why the event is firing twice :) 那可以解释为什么该事件触发两次:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM