How to bind Close command to a button

前端 未结 7 1262
时光说笑
时光说笑 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:49

    Actually, it is possible without C# code. The key is to use interactions:

    
    

    In order for this to work, just set the x:Name of your window to "window", and add these two namespaces:

    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
    

    This requires that you add the Expression Blend SDK DLL to your project, specifically Microsoft.Expression.Interactions.

    In case you don't have Blend, the SDK can be downloaded here.

提交回复
热议问题