在我的应用程序中有一个带有小图像的画布(不占用画布的整个空间)。当用户单击图像并在画布内拖动时,它会用黑线跟踪路径。直到这里一切正常。现在,我希望用户释放鼠标后立即删除路径。我正在使用MouseLeftButtonUp
来canvas
检测鼠标释放。现在的问题是这是随机工作的。有时它会触发,有时则不会。请帮忙。
XAML:
<Canvas Height="400" HorizontalAlignment="Center" Margin="10,10,0,0" Name="canvas1" VerticalAlignment="Center" Background="Aqua" Width="400">
<Image Canvas.ZIndex="30" Canvas.Left="10" Canvas.Top="10" Height="20" Name="dot1" Stretch="Uniform" Width="20" Source="/BoxIt;component/Images/dot.png" MouseLeftButtonDown="dot_MouseLeftButtonDown" />
</Canvas>
C#:
this.canvas1.MouseMove += new MouseEventHandler(canvas1_MouseMove);
this.canvas1.MouseLeftButtonUp += new MouseButtonEventHandler(canvas1_MouseLeftButtonUp);
C# 中的事件处理程序:
void canvas1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
// code to delete the path
}