Reputation: 269
I want to add a button to my UWP app that removes all the strokes from an InkCanvas
, but the suggested method inkCanvas.InkPresenter.Strokes.Clear()
isn't recognized as a valid command, is it obsolete or I am doing something else wrong?
Upvotes: 1
Views: 3011
Reputation: 306
Nothing really worked until I coded this out: This is on button click btw.
YourWindow.xaml.cs
private void ClearBtn_click(object sender, RoutedEventArgs e)
{
if(YourInkCanvaName.Strokes.Count != 0)
{
while (YourInkCanva.Strokes.Count > 0)
{
draw.Strokes.RemoveAt(draw.Strokes.Count - 1);
}
}
else
{
// DO NOTHING WHEN THERE IS NOTHING TO CLEAR
}
}
Upvotes: 0