How to Bind to window's close button the X-button

后端 未结 4 1867
长情又很酷
长情又很酷 2020-12-20 22:55

How I can bind one of my buttons on control to X Button that closes the window ? I just want to create cancel button that just closes the window. I am using MVVM in my code.

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-20 23:48

    If it's WPF (and provided I remember right) you can just use CallMethodAction from the parent as a behavior and utilize Close() method via just XAML. Something like;

    Parent Window x:Name="window"

    namespaces;

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

    -

    
    

    Hope this helps.

提交回复
热议问题