0

I'm using an Inkcanvas at my solution. So I want to delete after user confirm, like this...

XAML:

<InkCanvas Grid.RowSpan="3" Name="ink"  StrokeErasing="ink_StrokeErasing" />

C#:

private void ink_StrokeErasing(object sender, InkCanvasStrokeErasingEventArgs e)
{
    if (MessageBox.Show("Delete this stroke?", "", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
    {
        e.Cancel = true;
    }
}

After that, I can see the messagebox twice, :( This Wonder how that happened. Please let me konw about this.

2 Answers2

1

I tried to reproduce this error and used ink.EditingMode = InkCanvasEditingMode.EraseByStroke;

This only triggers the message box once.

When I use ink.EditingMode = InkCanvasEditingMode.Select; and press delete after selecting a stroke, the messagebox is not shown.

Then I used ink.EditingMode = InkCanvasEditingMode.EraseByPoint; and that caused the message box to appear multiple times because it is triggered for every single point of the stroke you are deleting.

Emond
  • 50,210
  • 11
  • 84
  • 115
0

Thanks emo. Actually I used "InkCanvasEditingMode.EraseByStroke" and I have to use this value. :( Anyway I guess the problem is mouse focus. I changed my code like this...

private void ink_StrokeErasing(object sender, InkCanvasStrokeErasingEventArgs e)
{
    if (Mouse.LeftButton == MouseButtonState.Released) { e.Cancel = true; return; }

    if (MessageBox.Show("Delete this stroke?", "", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
    {
        e.Cancel = true;
    }
}

It works fine :) I suspect that this is a bug.

JDee
  • 21
  • 1
  • 3