WPF: Canvas mouse events not firing on empty space

前端 未结 2 850
野性不改
野性不改 2020-12-05 04:20

I have set mouse events on a Canvas as follows:


...


        
相关标签:
2条回答
  • 2020-12-05 04:54

    Set the background color. It defaults to null.

    Use Background="White" for instance.

    0 讨论(0)
  • 2020-12-05 05:06

    A control with no background color set (explicitly or through styles etc) will default to having a background color of null - making it not hit-testable.

    If you set the background to "Transparent" (or anything other than null ({x:Null})) then it will be able to pick up the mouse events

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