Reputation: 14529
I'm using an InkPresenter control and I've set it up so I can drawn simple black lines on it, with this code:
private Stroke newstroke;
public MainPage()
{
InitializeComponent();
}
private void btnDownHandler(object sender, MouseButtonEventArgs e)
{
inkP.CaptureMouse();
newstroke = new Stroke();
//Add stylus points via Getter-method, use inkP as argument.
newstroke.StylusPoints.Add(e.StylusDevice.GetStylusPoints(inkP));
//Add captured strokes to canvas.
inkP.Strokes.Add(newstroke);
}
private void btnUpHandler(object sender, MouseButtonEventArgs e)
{
//Set stroke object to NULL and stop capturing the mouse.
newstroke = null;
inkP.ReleaseMouseCapture();
}
private void mouseMoveHandler(object sender, MouseEventArgs e)
{
//Check for NULL, see btnUpHandler
if (newstroke != null) {
//If not NULL, keep adding stylus points to the Stroke object.
newstroke.StylusPoints.Add(e.StylusDevice.GetStylusPoints(inkP));
}
}
My problem is: I want to implement a button, which I click, and it removes everything that was previously added to the InkPresenter.
I've tried inkP.Children.Clear();
but that didn't work. I've tried inkP.Strokes.Remove(newstroke)
. Didn't work either.
Is there no easy function to remove all
Upvotes: 2
Views: 343