locked
any way to recognize scale gesture in gridview

    Question

  • Hi:

       I want to scale items on gridview only by horizontally.Any suggestion?

       I tried some way,but all failed.

       1.custom gridview control,but failed

       2. add Manipulation event handler for gridview,but never receiver it in gridview_Frames_ManipulationDelta2 on when 2 fingers scale

              gridview_Frames->ManipulationMode = ManipulationModes::Scale;
              gridview_Frames->ManipulationStarted += ref new ManipulationStartedEventHandler(this,&MainPage::gridview_Frames_ManipulationStarted2);
              gridview_Frames->ManipulationCompleted += ref new ManipulationCompletedEventHandler(this,&MainPage::gridview_Frames_ManipulationCompleted2);
              gridview_Frames->ManipulationDelta += ref new ManipulationDeltaEventHandler(this,&MainPage::gridview_Frames_ManipulationDelta2);

       3. add PointerEventHandler for gridview and one GestureRecognizer,but it cause exception in  gridview_Frames_PointerPressed

               PointerEventHandler^ phandler = nullptr;
               phandler = ref new PointerEventHandler(this, &MainPage::gridview_Frames_PointerPressed);
               gridview_Frames->AddHandler(Control::PointerPressedEvent,phandler,true);
               phandler = ref new PointerEventHandler(this, &MainPage::gridview_Frames_PointerMoved);
               gridview_Frames->AddHandler(Control::PointerMovedEvent,phandler,true);
               phandler = ref new PointerEventHandler(this, &MainPage::gridview_Frames_PointerReleased);
               gridview_Frames->AddHandler(Control::PointerReleasedEvent,phandler,true);
               m_gestureRecognizerFrames = ref new Windows::UI::Input::GestureRecognizer();
               // Configure gesture recognizer
              m_gestureRecognizerFrames->GestureSettings = Windows::UI::Input::GestureSettings::ManipulationScale|Windows::UI::Input::GestureSettings::ManipulationScaleInertia;
              m_gestureRecognizerFrames->ManipulationStarted += ref new Windows::Foundation::TypedEventHandler<
              Windows::UI::Input::GestureRecognizer^, Windows::UI::Input::ManipulationStartedEventArgs^>(
         this, &MainPage::gridview_Frames_ManipulationStarted);

               m_gestureRecognizerFrames->ManipulationUpdated += ref new Windows::Foundation::TypedEventHandler<
        Windows::UI::Input::GestureRecognizer^, Windows::UI::Input::ManipulationUpdatedEventArgs^>(
         this, &MainPage::gridview_Frames_ManipulationUpdated);

               m_gestureRecognizerFrames->ManipulationCompleted += ref new Windows::Foundation::TypedEventHandler<
        Windows::UI::Input::GestureRecognizer^, Windows::UI::Input::ManipulationCompletedEventArgs^>(
         this, &MainPage::gridview_Frames_ManipulationCompleted);

          void MainPage::gridview_Frames_PointerPressed(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
          {
                 if (m_gestureRecognizerFrames != nullptr)
                {

                      m_gestureRecognizerFrames->ProcessDownEvent(e->GetCurrentPoint(gridview_Frames)); //it cause exception (invalid parameters)
                 }

           } 

          Help me!

    Tuesday, December 4, 2012 3:10 AM

Answers

  • Hi yxhzjyk,

    The problem you are running into here is that the GridView's ScrollViewer is taking over the manipulations to handle the scrolling. To handle the manipulations yourself you will need to turn off the GridView's manipulations.

    To allow both based on context you can disable the GridView's manipulations when the user touches your items. This will let you do custom scaling manipulations on the items. When the item manipulation is done then reenable the GridView's manipulations.

    --Rob

    Saturday, December 8, 2012 2:31 AM
    Owner

All replies

  • note 3: void MainPage::gridview_Frames_PointerPressed(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
          {
                 if (m_gestureRecognizerFrames != nullptr)
                {

                      m_gestureRecognizerFrames->ProcessDownEvent(e->GetCurrentPoint(gridview_Frames)); //it cause exception (invalid parameters),It say "Failed to
    start tracking the pointer,because it is already being tracked

          }

           }

    Tuesday, December 4, 2012 3:25 AM
  • Hello,

     

    Thanks for your feedback, I will involve more experts to investigate it.

     

    Best regards,

    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, December 6, 2012 8:14 AM
  • Hi yxhzjyk,

    The problem you are running into here is that the GridView's ScrollViewer is taking over the manipulations to handle the scrolling. To handle the manipulations yourself you will need to turn off the GridView's manipulations.

    To allow both based on context you can disable the GridView's manipulations when the user touches your items. This will let you do custom scaling manipulations on the items. When the item manipulation is done then reenable the GridView's manipulations.

    --Rob

    Saturday, December 8, 2012 2:31 AM
    Owner