Essentially what I’m trying to do is trigger a sort of ‘dirty’ state for my canvas, so that I know if there are unsaved changes.
Is there an event in the WPF InkCanvas that I can use to handle any time when the strokes change?
If there isn’t, what events should I listen to for the equivalent? My first guess would be these:
StrokeCollected
StrokeErased
StrokesReplaced
Though I could be wrong, and be missing an edge case.
Note: It’s not a big deal if I get false positives (marked dirty when it is in fact not), but I don’t want false negatives.
It seems like these events will do the job:
InkCanvas.StrokesReplaced(occurs when the Strokes property is set)StrokeCollection.StrokesChanged(occurs when a stroke is added or removed)Stroke.StylusPointsChanged(occurs when the shape of a stroke is changed)Stroke.StylusPointsReplaced(occurs when the StylusPoints property is set)Stroke.DrawingAttributesChanged(occurs when the attributes of a stroke are changed)Stroke.DrawingAttributesReplaced(occurs when the DrawingAttributes property is set)In my case, I never replace properties, or change drawing attributes, so I only use
StrokeCollection.StrokesChangedandStroke.StylusPointsChanged. Here is a snippet of my code.