Search code examples
c#uwpuwp-xamlinkcanvas

UWP-xaml InkCanvas: Is there a way to deny painting on specific zones?


I am trying to make a UI prototype for a bus route design app. The intended behaviour is to let the user paint with a brush over the streets, but not over buildings. The idea is to get something like you see in the image below where the pink line represents the route that the user just painted.

I am currently using a basic InkCanvas and InkToolbar in order to do this. My problem is that I have no idea on how to prevent users from painting over buildings. I tried to create several InkCanvas, each one of them representing a unique street, but that's a very clunky solution. Should I stick to this "solution" or is there any other thing that allows me to prevent the user from painting?

pink line represents the route that the user just painted


Solution

  • UWP-xaml InkCanvas: Is there a way to deny painting on specific zones?

    Great question, for your requirement, the better way is that draw line in MapControl with MapPolyline.

    If you want to draw the line with ink-canvas, You need to declare that the building is not available. and please check official code sample scenario 8. When the stroke cross the circle, it will be removed.