I use Shapes and Canvas, I want to do something like mapeditor. When the mouse moves around the canvas, I draw the actually selected object onto the canvas in the mouse position at each step, so whoever uses the program can see how it will look if the object is placed there.
And when I click, I add the current object / position to the list that contains the placed elements that need to be drawn on the canvas in each update.
The problem is that the mouse movement handler is active (attached to the canvas), then the click event does not always fire, I need to click continuously. In about ten clicks to place an item. If the mouse move event is not bound, the click works fine.
I made a GIF to demonstrate my problem.
Here when the mouse move event is used

, and that's when not

I think, because the move event activates event processing, and there is no resource to fire the click event.
How could I use two events together?
EDIT
As I said, I give the code for example.
I have a model for a canvas with a name mapEditorModel. An important property for us is mapEditorModel.MapObjects, which is a list containing the elements that need to be selected on the canvas.
The list contains a wrapper object, it contains a lot of information about the elite, which is important for us, is that it contains a preliminary assembly form for drawing.
I have a function that draws elms on canvas:
private void DrawElementOnCanvas(MapElementContainer item)
{
Rectangle shape = item.Shape;
CanvasElement.Children.Add(shape);
Canvas.SetLeft(shape, item.Position.X);
Canvas.SetTop(shape, item.Position.Y);
}
And I have a method updateCanvas():
private void updateCanvas()
{
CanvasElement.Children.RemoveRange(0, CanvasElement.Children.Count);
foreach (MapElementContainer item in mapEditorModel.MapObjects)
{
DrawElementOnCanvas(item);
}
}
And two event methods:
private void CanvasElement_MouseMove(object sender, MouseEventArgs e)
{
updateCanvas();
MapElementContainer mapObject = new MapElementContainer();
mapObject.Position = e.GetPosition((Canvas)sender);
mapObject.MapElement = new ContainerMapObject();
mapObject.CurrentRotateDegree = mapEditorModel.CurrentRotateDegree;
mapObject.Shape = BuildShape(mapObject);
DrawElementOnCanvas(mapObject);
}
private void CanvasElement_MouseDown(object sender, MouseButtonEventArgs e)
{
MapElementContainer mapObject = new MapElementContainer();
mapObject.Position = e.GetPosition((Canvas)sender);
mapObject.MapElement = new ContainerMapObject();
mapObject.CurrentRotateDegree = mapEditorModel.CurrentRotateDegree;
mapObject.Shape = BuildShape(mapObject);
mapEditorModel.MapObjects.Add(mapObject);
updateCanvas();
}
EDIT 2
, - , , , ?