I'm writing drawing application using C# WPF InkCanvas. Problem is, When I set UseCustomCursor = "True", and Cursor = "Hand", the cursor on InkCanvas jumps to the first point of a stroke. Not all times but sometimes. Not on mouse movement,
but on stylus movement.
Code here.
<Window x:Class="CursorJump.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:CursorJump" mc:Ignorable="d" Title="CursorJump" Height="350" Width="525"><Grid><InkCanvas UseCustomCursor="True" Cursor="Hand" ><InkCanvas.DefaultDrawingAttributes><DrawingAttributes Height="3" Width="3" Color="SlateGray"/></InkCanvas.DefaultDrawingAttributes></InkCanvas></Grid></Window>
So I researched MSDN and stackoverflow. All I found is the fact that WPF have diffrent two or more rendering thread: dynamic rendering thread and UI thread.
As the user draws a stroke, DynamicRenderer renders the ink on a separate thread so the ink appears to "flow" from the pen even when the UI thread is busy. The DynamicRenderer builds a visual tree on the dynamic rendering thread as it collects stylus points. When the user finishes the stroke, the DynamicRenderer asks to be notified when the application does the next rendering pass. After the application completes the next rendering pass, the DynamicRenderer cleans up its visual tree. The following diagram illustrates this process.
I think the ink threading model causes this abnormal 'cursor jump' phenomenon. As stylus moves, Hand cursor follows stylus raw input point (in dynamic rendering thread) and when stylus input fragment is processe to stroke, my Hand cursor jump to starting
point of the stroke(in UI thread).
Am I right? if then, How could I fix this problem?