【发布时间】:2014-02-05 01:23:20
【问题描述】:
我有一个由 UserControls 而不是 Windows 组成的 WPF 表单。与 Windows 不同,UserControl 没有UserControl.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>
【问题讨论】: