Reputation: 269
I need to save all the strokes of an InkCanvas
in a variable (not a file) and later load them in the InkCanvas
when the user needs it. The problem is that I get an unknown error every time I try to load the strokes.
This is the code I'm using to load them:
foreach (InkStroke stroke in StrokesList)
{
var strokeBuilder = new InkStrokeBuilder();
strokeBuilder.SetDefaultDrawingAttributes(stroke.DrawingAttributes);
System.Numerics.Matrix3x2 matr = stroke.PointTransform;
IReadOnlyList<InkPoint> inkPoints = stroke.GetInkPoints();
InkStroke stk = strokeBuilder.CreateStrokeFromInkPoints(inkPoints, matr);
InkCanvas.InkPresenter.StrokeContainer.AddStroke(stk);
}
I also tried InkCanvas.InkPresenter.StrokeContainer.AddStrokes(StrokesList);
but it doesn't work either
EDIT: I'm saving the strokes like this: IReadOnlyList<InkStroke> StrokesList = inkCanvas.InkPresenter.StrokeContainer.GetStrokes();
Upvotes: 0
Views: 182
Reputation: 7233
If all you require is storing and then restoring the strokes, I recommend using StrokeContainer.SaveAsync to a InMemoryRandomAccessStream and then just loading that with StrokeContainer.LoadAsync.
Upvotes: 1