I'm working with WPF and Canvas and TranslateTransform. (Originally I worked with the "manipulation" feature, whereby touch gestures are translated to MatrixTransform transformations but the problem is evident also with a simple TranslateTransform).
I use a TranslateTransform to move the origin (i.e. the (0,0) point) of my canvas into the middle of my window. I can happily draw objects in the negative coordinate space, but I can't receive mouse input for this region...I only receive MouseDown events when the mouse is in the positive quadrant, as confirmed by a breakpoint and by program behaviour.
Why can I draw in an area I can't receive input in? In the positive quadrant, the mouse input and the drawing are perfectly aligned. Is this a bug in WPF? I've tried moving the MouseDown event handler into the parent element, a DockPanel, but this behaves no differently even though the TranslateTransform is applied at the Canvas element. (I have a Canvas inside a DockPanel inside a Window).
Some fragments of my app:
<Canvas Name="canvas" MouseDown="Canvas_MouseDown" MouseMove="Canvas_MouseMove"
MouseUp="Canvas_MouseUp" MouseWheel="Canvas_MouseWheel"
IsManipulationEnabled="true">
<Canvas.Background>
<SolidColorBrush Color="Black" />
</Canvas.Background>
</Canvas>
private void Canvas_MouseDown(object sender, MouseButtonEventArgs e)
{
currentPoint = inverseRenderTransform.Transform(e.GetPosition(this));
...
inverseRenderTransform.Transform
if you would calle.GetPosition((IInputElement)sender)
ore.GetPosition(canvas)
. - Clemens