2011-05-16 61 views
2

我使用InkPresenter控件,我已經將它設置就可以了,所以我可以繪製簡單的黑色線條,與此代碼:從InkPresenter控件刪除所有油墨

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)); 
    } 
} 

我的問題是:我想要實現一個按鈕,單擊它,它將刪除以前添加到InkPresenter的所有內容。我試過inkP.Children.Clear();但是沒有成功。我試過inkP.Strokes.Remove(newstroke)。也沒有工作。

有沒有簡單的函數刪除所有

回答

1

嘗試​​,不Children.Clear();