Beantwortet how can I Check PointerCaptured or not?

  • Mittwoch, 11. April 2012 09:00
     
     

    I have a Canvas within which i am trying to draw a rectangle on pointer move ment.

    How can i know weater pointercaptured or not??

    crrentle i am using this:

    OnPointerDown(Object sender, PointerEventArgs e)

    {

    Canvas canvas = sender as Canvas;

     canvas.CapturePointer(e.Pointer);

    }

    OnpointerMove(Object sender, PointerEventArgs e)

    {

    if ( ?????) // what here

    {

    //keep drawing rectangle

    }

    }

    OnPointerUp(Object sender, PointerEventArgs e)   {

    Canvas canvas = sender as Canvas;

     canvas.ReleasePointerCaptures();

    }

    Thanks in advance


Alle Antworten

  • Mittwoch, 11. April 2012 14:06
     
     Beantwortet

    UIElement exposes a PointerCaptures property. Will that do what you need?


    Rebecca M. Riordan

  • Donnerstag, 12. April 2012 02:58
    Moderator
     
     Beantwortet

    As Rebecca suggests you could check UIElement.PointerCaptures to see if the pointer being moved is captured.

    I usually set a flag in OnPointerDown to indicate which pointers were in the drawing state and then clear the flag in OnPointerUp or OnPointerCaptureLost. This lets me store more information about what each pointer is doing than just knowing if it is captured.

    Don't forget to handle multiple pointers.

    --Rob