MouseLeftButtonUp在WP7中不会一直触发

时间:2012-09-11 14:12:36

标签: c# windows-phone-7 mouseleftbuttonup

在我的应用程序中,有一个带有小图像的画布(不占据画布的整个空间)。 当用户点击图片并在画布内拖动时,它会用黑线跟踪路径。直到这里一切正常。现在,我想要在用户释放鼠标保持时立即删除路径。我在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#中的Eventhandler:

 void canvas1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
       // code to delete the path
    }

1 个答案:

答案 0 :(得分:3)

在Windows Phone中,我们建议使用TapHold和Manipulation *方法代替鼠标相关事件。

请阅读this了解详情。