2012-12-10 3 views
1

상황 : WinRT 응용 프로그램, 기본 페이지의 캔버스. 캔버스에는 여러 어린이가 있습니다. 사용자가 캔버스를 탭하고 포인터를 움직일 때 스크롤하려고합니다. 모든 것이 정상적으로 작동하지만 관성 스크롤을 에뮬레이션하는 방법을 알지 못합니다.WinRT, C#, 캔버스 및 어린이 관성 스크롤

코드 : 좀 캔버스 이벤트를 구독 한

private GestureRecognizer gr = new GestureRecognizer(); 
public MainPage() 
     { 
      this.InitializeComponent(); 


      gr.GestureSettings = GestureSettings.ManipulationTranslateInertia; 
      gr.AutoProcessInertia = true; 
     } 

는 :

//Pressed 
private void Canvas_PointerPressed(object sender, PointerRoutedEventArgs e) 
     { 
      if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch) 
      { 


       var _ps = e.GetIntermediatePoints(cnvMain); 
       if (_ps != null && _ps.Count > 0) 
       { 
        gr.ProcessDownEvent(_ps[0]); 
        e.Handled = true; 

        Debug.WriteLine("Pressed"); 
       } 
       initialPoint = e.GetCurrentPoint(cnvMain).Position.X; 
      } 
     } 



//Released 
private void Canvas_PointerReleased(object sender, PointerRoutedEventArgs e) 
     { 
      if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch) 
      { 

       var _ps = e.GetIntermediatePoints(cnvMain); 
       if (_ps != null && _ps.Count > 0) 
       { 
        gr.ProcessUpEvent(_ps[0]); 
        e.Handled = true; 

        Debug.WriteLine("Released"); 

      } 
     } 

// Moved 
private void Canvas_PointerMoved(object sender, PointerRoutedEventArgs e) 
     { 

      if (gr.IsActive || gr.IsInertial) 
      { 

            gr.ProcessMoveEvents(e.GetIntermediatePoints(null)); 


// Here is my code for translation of children 
       e.Handled = true; 
      } 
     } 

그래서, 캔버스 아이를 번역 할 수 있지만 관성이 없다. 어떻게 활성화 할 수 있습니까?

특정 데이터 때문에 불행히도 GridView 또는 ListView를이 응용 프로그램에서 사용할 수 없습니다.

감사합니다.

답변