Using OnKeyDown and OnPreviewKeyDown in a Canvas

前端 未结 2 1792
栀梦
栀梦 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);

    0 讨论(0)
  • 2021-01-27 02:49

    Can you please check by setting Focusable="True" for canvas. Hope it works.

    0 讨论(0)
提交回复
热议问题