我需要将InkCanvas
的所有笔划保存在变量(不是文件)中,然后在用户需要时将其加载到InkCanvas
中。问题是每次我尝试加载笔划时都会收到未知错误。
这是我用来加载它们的代码:
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);
}
我也试过了InkCanvas.InkPresenter.StrokeContainer.AddStrokes(StrokesList);
,但它无效
编辑:我正在保存这样的笔画:IReadOnlyList<InkStroke> StrokesList = inkCanvas.InkPresenter.StrokeContainer.GetStrokes();
答案 0 :(得分:1)
如果您只需要存储然后恢复笔画,我建议您使用StrokeContainer.SaveAsync加InMemoryRandomAccessStream,然后只需加载StrokeContainer.LoadAsync。