WPF, Shapes
I have a custom Shape, and try to implement MouseClick and MouseDoubleClick stuff on it.
By eg. I need to open a information window about MyShape OnClick and select it OnDoubleClick.
The stub is the following:
public class MyShape : Shape
{
public Point Point1, Point2;
public MyShape() : base() { }
protected override Geometry DefiningGeometry
{
get { return new LineGeometry(Point1, Point2); }
}
protected override void OnMouseUp(MouseButtonEventArgs e)
{
base.OnMouseUp(e);
if (e.ClickCount == 1)
{
// Open Informational Window
}
else if (e.ClickCount == 2)
{
// Select Item
}
}
}
Every time I doubleclick both // Only do MouseClick and // Only do MouseDoubleClick happens.
Is there any way to avoid this in WPF, .NET 4?
Between first click and second click in double click I think there is a time around 50 and 400 millisecond, So the bellow code is not a best one but do the trick: