我有一个由 UserControls 而不是 Windows 组成的 WPF 表单。与 Windows 不同,UserControl 没有 aUserControl.Close
或UserControl.Closing
. 当我的应用程序关闭时,我需要能够通过单击应用程序右上角熟悉的红色 x 来运行代码。有没有人这样做过?请记住,我正在使用 MVVM。
这是页面的 XAML:
<UserControl x:Class="ClassName"
<!--etc..-->
>
<Grid>
<Grid.ColumnDefinitions>
<!--Columns-->
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<!--Rows-->
</Grid.RowDefinitions>
<!--WPF Content-->
</Grid>
</UserControl>