How to dismiss a popup in Silverlight when clicking outside of the control?

后端 未结 7 2372
南旧
南旧 2020-12-29 05:24

In my Silverlight UI, I have a button that when clicked pops up a control with some filtering parameters. I would like this control to hide itself when you click outside of

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-29 05:53

    One way is to put your control on a transparent canvas that fills the entire Silverlight surface. When the canvas is clicked close the canvas and control. It is important to ensure that the Background brush of the canvas is set to "Transparent" if you want to receive mouse events.

    An alternate method that I have not had success with is using mouse capture in Silverlight and detecting when the mouse is clicked outside of the popup.

提交回复
热议问题