Using OnKeyDown and OnPreviewKeyDown in a Canvas

前端 未结 2 1793
栀梦
栀梦 2021-01-27 02:23

I have a DragCanvas class that inherits from Canvas and that implements functionality in order to grab, drag and resize elements. The DragCanvas class is very similar to the one

2条回答
  •  走了就别回头了
    2021-01-27 02:46

    Set Focusable="True" for your canvas, then put this snippet into your window class and set DragCanvas into focus. Hope this helps you.

    Loaded += (x,y) => Keyboard.Focus(DragCanvas);

提交回复
热议问题