【发布时间】:2017-02-16 16:38:57
【问题描述】:
我正在尝试擦除在 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”的定义。你能举例说明如何实现它吗?
-
这很奇怪,它应该有一个Strokes Property
-
我正在使用 vs2015,我的 uwp 应用程序目标版本是 build 14393。它给出了错误