How to bind Close command to a button

前端 未结 7 1237
时光说笑
时光说笑 2020-11-30 19:09

The easiest way is to implement ButtonClick event handler and invoke Window.Close() method, but how doing this through a Command bindi

7条回答
  •  有刺的猬
    2020-11-30 19:36

    The simplest solution that I know of is to set the IsCancel property to true of the close Button:

    No bindings needed, WPF will do that for you automatically!

    Reference: MSDN Button.IsCancel property.

提交回复
热议问题