locked
which event i should use in xaml to capture the stroke clicked with a mouse RRS feed

  • Question

  • hi,
     May i know which event i should use in xaml to capture the stroke clicked with a mouse? In my application the strokes are added programatically. Is there any event that will be called when i clicked on one of the strokes i added? I want to do some changes in the appearance of the strokes by selecting from a context menu.
    Thanks in advance

    Tuesday, October 30, 2007 2:35 AM

Answers

  • Hi nyc9,

     

    you can respond to the PreviewMouseDown (or PreviewLeft/RightButtonDown) and then perform a hit-test on InkCanvas's StrokeCollection.

     

    Here is some sample code:

    Code Block

    void OnPreviewMouseDown(object sender, MouseEventArgs e)

    {

      Point pos = e.GetPosition(inkCanvas);

      StrokeCollection hitStrokes = inkCanvas.Strokes.HitTest(pos, 2d);

      foreach (Stroke stroke in hitStrokes)

      {

        // add your code to change the appearance here

      }

    }

     

     

     

    Thanks,

    Stefan Wick

     

    Microsoft - Windows Experience

    Tuesday, October 30, 2007 4:18 AM