2

Hi I have no ide why it isn't work. It looks like I can't use this event on InkCanvas.

XAML

<Window x:Class="PolyLine.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<StackPanel >
    <Button Name="Button1">Clear</Button>
    <InkCanvas x:Name="MC" MouseLeftButtonDown="MC_MouseLeftButtonDown" MouseRightButtonDown="MC_MouseRightButtonDown" MouseMove="MC_MouseMove" Background="White"  Height="300" Width="497" ></InkCanvas>
</StackPanel>

Code Behind

private void MC_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    polylinePoints.Add(e.GetPosition(MC));
}
Malv20
  • 159
  • 4
  • 11
  • Are you sure this is the topmost element? You can add Canvas.ZIndex="1000" (or another suitably big number) to force it to the front. – Nzc Feb 14 '12 at 09:04

1 Answers1

6

Apparently the InkCanvas handles the MouseLeftButtonDown event internally to initiate the drawing of an ink stroke. You could instead use the PreviewMouseLeftButtonDown event, but you should be careful with what you do. In an InkCanvas a user would usually expect to start drawing a stroke when he presses the left mouse button.

Clemens
  • 123,504
  • 12
  • 155
  • 268