我有点混淆如何处理手势点击事件? 当我点击我的手机屏幕时,手势点击事件会自动触发两次。但我只想要一次
我的代码是
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));
}
答案 0 :(得分:1)
正如我在你的回答评论中提到的那样,确保你没有意外地添加了两次事件处理程序:
g1.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(g1_Tap);
这可以解释为什么事件发射两次:)