0
我試圖擦除inkcanvas中單擊繪製的線條。 我的要求是,如果我在給定的區域上繪製一條線或任何圖案,它將刪除所有繪製在一個點擊線,並再次繪製任何東西,然後單擊'擦除'按鈕將清除當前屏幕上繪製的所有線。試圖擦除inkcanvas中單擊一條線繪製
的XAML
<Grid x:Name="Bg_BigRect" Background="White"
Width="310" Height="440"
RelativePanel.Below="Bg_Rect"
Margin="24,10,0,0">
<Image x:Name="Trans_Tex" Source="WorkBook/T0.png"
Margin="-10,0,0,20"
Width="310" Height="370"/>
<InkCanvas x:Name="ink"/>
</Grid>
C#代碼
public WorkBook()
{
this.InitializeComponent();
ink.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Touch;
// Set initial ink stroke attributes.
InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();
drawingAttributes.Color = Windows.UI.Colors.Black;
drawingAttributes.IgnorePressure = false;
drawingAttributes.FitToCurve = true;
ink.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
}
private void W_ClearTap(object sender, TappedRoutedEventArgs e)
{
this.ink.InkPresenter.InputProcessingConfiguration.Mode = InkInputProcessingMode.Erasing;
}
參考圖像
'ink.InkPresenter.Strokes.Clear()'。順便說一句。這是一個奇怪的方式來繪製一個'A' –
@ManfredRadlwimmer我試過了,但它給出了錯誤「InkPresenter」不包含「Strokes」的定義。你能舉例說明如何實現它。 – anuj
這很奇怪,它應該有一個[Strokes Property](https://msdn.microsoft.com/en-us/library/system.windows.controls.inkpresenter.strokes(v = vs.110).aspx) –