uwpinkcanvaseraser

Erasing portion of a stoke in UWP


I am using the new Ink technology for Windows 10, by using InkCanvas/InkPresenter in UWP. Ink rendering is really nice, except I can't seem to be able to erase only a portion of a stroke. I am looking at OneNote, that I am assuming is using the same technology, and they do offer erasing of portion of a stroke. I know this wasn't possible when the InkCanvas/InkPresenter was first introduced, but I was wondering if there is a method to achieve this? Some way to mask the stroke to fake the eraser, maybe? Anyone has a suggestion?


Solution

  • You can have a look at Microsoft's Coloring book sample where you can erase cell(Portion of stroke). They have created a Custom InkToolbar with flood fill, erase cell and much more.

    https://github.com/Microsoft/Windows-appsample-coloringbook

    Hope it helps.

    Edit

    You can intercept default inkcanvas events and set handler to avoid the event to take place.

    CoreInkIndependentInputSource core = CoreInkIndependentInputSource.Create(inkCanvas.InkPresenter); core.PointerPressing += ViewModel.Core_PointerPressing; 
    core.PointerReleasing += ViewModel.Core_PointerReleasing; 
    core.PointerMoving += ViewModel.Core_PointerMoving;