Answered by:
Stylus position on canvas

Question
-
Hello,
I have a canvas and I want when I touch the screen with the stylus display the coordinate of the position where the stylus touch the canvas. (stylus not mouse)
Any help would be greatly appreciated!
Harold
Friday, August 25, 2017 12:57 AM
Answers
-
You could handle Stylusdown.
https://msdn.microsoft.com/en-us/library/system.windows.uielement.stylusdown(v=vs.110).aspx
I think you can then do getposition(canvas).
https://msdn.microsoft.com/en-us/library/system.windows.input.styluseventargs.getposition(v=vs.110).aspx
- Marked as answer by JH_Levasseur Monday, September 11, 2017 12:56 AM
Friday, August 25, 2017 8:33 AM
All replies
-
Hi JH_Levasseur,>>I have a canvas and I want when I touch the screen with the stylus display the coordinate of the position where the stylus touch the canvas. (stylus not mouse)
You can get the Position by the StylusEventArgs
public Readxmlspantotextblock() { InitializeComponent(); this.StylusDown += Readxmlspantotextblock_StylusDown; this.StylusMove += Readxmlspantotextblock_StylusMove; } private void Readxmlspantotextblock_StylusMove(object sender, StylusEventArgs e) { Point pos = e.GetPosition(this); } private void Readxmlspantotextblock_StylusDown(object sender, StylusDownEventArgs e) { Point pos = e.GetPosition(this); }
The following link may be helpful for you.
WPF and multi-touch
https://www.codeproject.com/Articles/692286/WPF-and-multi-touchBest Regards,
Yohann Lu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- Edited by Yong LuMicrosoft contingent staff Friday, August 25, 2017 8:59 AM
- Proposed as answer by Andy ONeill Monday, August 28, 2017 2:06 PM
Friday, August 25, 2017 8:30 AM -
You could handle Stylusdown.
https://msdn.microsoft.com/en-us/library/system.windows.uielement.stylusdown(v=vs.110).aspx
I think you can then do getposition(canvas).
https://msdn.microsoft.com/en-us/library/system.windows.input.styluseventargs.getposition(v=vs.110).aspx
- Marked as answer by JH_Levasseur Monday, September 11, 2017 12:56 AM
Friday, August 25, 2017 8:33 AM -
That's works fine!
Thanks :-)
Monday, August 28, 2017 12:43 AM -
Hi JH_Levasseur,I am glad to know you solved. It would be appreciated if you could close the thread by marking the helpful solution as an answer. This will help other members to find the solution quickly if they have faced the similar issue.
You can start a new thread if you have a new question. Please don't ask several questions in the same thread.
Your understanding and cooperation will be grateful.
Best Regards,
Yohann Lu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Monday, August 28, 2017 1:21 AM