Trap mouse in WPF
I have a canvas in which I have an image. I can move that image using the mouse (drag-n-drop). I want to prevent the user to move the image outside of the canvas. Is there any way I can trap the mouse pointer so it can only move inside the canvas? So when the user tries to move the mouse outside the canvas, the cursor would remain at the edge of the canvas. One example of this behavior would be when moving a window, you can't move it on the taskbar. When you try to move it on the taskbar, the mouse cursor stays on the edge of the taskbar, refusing to move on top of the taskbar. Martin