2014-05-23 2 views
0

내 응용 프로그램에는 홈 페이지와 2 개의 다른 페이지가 있습니다. 그래서 한 페이지에서 다른 페이지로 이동하고 싶습니다. 그리고 오른쪽에서 왼쪽으로 가로로 스 와이핑 할 때와 왼쪽에서 오른쪽으로 가로 스 와이핑 할 때 홈 페이지로 이동해야합니다.Windows phone 앱에서 제스처를 기반으로 탐색을 수행하는 방법은 무엇입니까?

오른쪽에서 왼쪽으로 스 와이프하면 홈 페이지에 있습니다 (홈 페이지 ---> Page1, 다시 스 와이프 ---> Page2, 다시 스 와이프 ---> Page1 ...처럼 .... .) 그리고 왼쪽에서 오른쪽으로 스 와이프하면 모든 페이지에서 홈 페이지로 이동해야합니다. Windows Phone 8 앱에서이 작업을 수행하는 방법은 무엇입니까?

내 코드 :

if (e.HorizontalVelocity < 0) //when it is true it should navigate to next index value 
      { 
       try 
       { 

        Pivot_Main.SelectedIndex++;// here every time it's showing the same index value it is not incrementing 
        switch (Pivot_Main.SelectedIndex) 
        { 
        case 0: 
         Pivot_Main.SelectedIndex = 0; 
         txtBlock_Pivot_Heading.Text = "Temperature"; 
         var brush = new SolidColorBrush(Color.FromArgb(0xFF, 0x8C, 0xC6, 0x3F)); 
         b_celcius = true; 
         temperature_Page_Clear(); 
         txtBlock_OptText.Text = "ºC"; 
         btn_OptText.Content = "ºC"; 
         Grid_PivotHeading.Background = brush; 
         Canvas_Home.Background = brush; 
         Canvas_DisplayName.Width = 55; 
         // btn_OptText.SetValue(Canvas.LeftProperty, 380.0); 
         break;     
        case 1: 
         Pivot_Main.SelectedIndex = 1; 
         txtBlock_Pivot_Heading.Text = "Length"; 
         length_Page_Clear(); 
         b_meter = true; 
        } 
       } 
      } 

나를 제발 도와주세요, 정품 도움에 감사드립니다.

+1

를 얻을 수 있습니다 머리말은 당신에게이 효과를 줄 수 있습니다. –

답변

0

여기에는 여러 옵션이 있습니다.

한 페이지에서 작업을 수행 할 수 있다면 Pivot 또는 Panorama 컨트롤로 충분할 것입니다. 당신은 모든 페이지가 다를 것이 필요하고 다음 한 페이지에서 다른 페이지로 이동 NavigationService.Navigate()을 사용하려는 경우 또한

, 당신은 우선은 왼쪽/오른쪽 HorizontalVelocity 통해 통해 와이프 처리하기 위해 관리 할 수있는 이벤트가 Flick라고 가지고 그 사건 중 VerticalVelocity.

Flick Gesture를 사용하려면 xaml w.r.t.에이 코드를 추가해야합니다.

<toolkit:GestureService.GestureListener> 
       <toolkit:GestureListener Flick="OnFlick"/> 
    </toolkit:GestureService.GestureListener> 

및 .cs 핸들러에서 : 당신의 UI 요소에 제스처 지원의

private void OnFlick(object sender, FlickGestureEventArgs e) 
    { 
     // User flicked towards left 
     if (e.HorizontalVelocity < 0) 
     { 
     //your respective navigation to other page 
     } 
     // User flicked towards right 
     if (e.HorizontalVelocity > 0) 
     { 
     //your respective navigation to other page 
     } 

세부 사항은 당신이 아마 최고의 솔루션 있지만 비어있는 피벗 제어하지 here

+0

빨리 스 와이프 할 때 제대로 작동하지만 페이지에서 느리게 스 와이프하면 제대로 응답하지 않습니다. – user3162111

+0

그 사이에 멈추지 않으면 Flick 이벤트를 인식해야합니다. 드래그 이벤트도 있습니다. 마지막으로 드래그 이벤트를 시도 할 수 있습니다. – vITs

관련 문제