I am trying to create a note app myself. I want the app to have several pages, each with their own 'InkCanvas'. I've managed this, but whenever I leave the page the 'collection/list' of 'InkStrokes' gets cleared.
My solution is to create a list of 'InkStrokes'. Save that list in the pages.xaml.cs and then load that list into the 'InkCanvas' whenever the page is navigated onto again.
Here I am trying to first get the strokes and then add them back:
var strokes = inkCanvas.InkPresenter.StrokeContainer.GetStrokes();
foreach (var stroke in strokes)
{
inkCanvas.InkPresenter.StrokeContainer.AddStroke(stroke);
}
I've also tried this without luck:
private IEnumerable<InkStroke> pageStrokes;
pageStrokes = new IEnumerable<InkStroke> //Line continues
inkCanvas.InkPresenter.StrokeContainer.GetStrokes();
inkCanvas.InkPresenter.StrokeContainer.AddStrokes(pageStrokes);
I suspect my problem is due to mismatched types of data. It would be very helpful if anyone answering this could explain a little about a possible solution and why it works.
In advance, many thanks to you kind internet strangers.