【问题标题】:Trying to erase the line drawn on one click in inkcanvas试图擦除在inkcanvas中一键绘制的线条
【发布时间】: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。它给出了错误

标签: xaml uwp


【解决方案1】:

对于 UWP 应用,您可以使用InkStrokeContainer.Clear 方法。例如:

ink.InkPresenter.StrokeContainer.Clear();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-29
    • 1970-01-01
    • 2013-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多