01 xaml
<Button Width="80" Command="{Binding CancelCmd}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"> </Button>
02 后台cs
private CommandBase cancelCmd; public CommandBase CancelCmd { get { if (cancelCmd == null) { cancelCmd = new CommandBase(CloseApp, CancelCanExcute); } return cancelCmd; } } void CloseApp(object o) { var win = o as System.Windows.Window; win.Close(); } bool CancelCanExcute(object o) { return true; }