2013-02-20 65 views
2

我有下面的代码,但它不工作任何人都可以告诉我需要做什么变化才能使它工作。如何在Windows Phone 8中处理ManipulationCompleted事件?

Mainscroll.ManipulationCompleted += new EventHandler<System.Windows.Input.ManipulationCompletedEventArgs>(Mainscroll_completed); 
private void Mainscroll_completed(object sender, System.Windows.Input.ManipulationCompletedEventArgs e) 
     { 
      UIElement target = sender as UIElement; 
      target.AddHandler(UIElement.ManipulationCompletedEvent, new EventHandler(layoutroot), true); 
      // throw new NotImplementedException(); 
     } 

     private void layoutroot(object sender, EventArgs e) 
     { 
      MessageBox.Show("done"); 
     } 
+0

它是完全不清楚什么是你想达到的,什么是不加工。你为什么要调用'target.AddHandler ...'? – Haspemulator 2013-02-20 11:24:48

+0

当我们滚动时,我想在滚动结束时处理事件。我想知道当我到达滚动结尾时处理哪个滚动事件,以便我可以处理Scollviewer的ManipulationCompleted事件。我正在使用这些代码的Windows 8手机,我已经在网络阅读,如果ManipulationCompleted不起作用,那么我们必须使用target.Addhandler。 – Thomas 2013-02-20 11:38:06

回答

0

替换此行:

Mainscroll.ManipulationCompleted += 
    new EventHandler<System.Windows.Input.ManipulationCompletedEventArgs>(Mainscroll_completed); 

这一行:

this.Mainscroll.AddHandler(
    Pivot.ManipulationCompletedEvent, 
    new EventHandler<ManipulationCompletedEventArgs>(Mainscroll_completed), true); 

,并删除:

target.AddHandler(UIElement.ManipulationCompletedEvent...... 
相关问题