我一直在尝试修改跳转列表中“关闭窗口”按钮的行为(显示“您确定”对话框还是最小化Skype中的窗口应用程序)。
你知道怎么做吗?
答案 0 :(得分:0)
您需要为您的窗口处理Closing
事件:
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (MessageBox.Show("Are you sure?", "Closing app", MessageBoxButton.YesNo) == MessageBoxResult.No)
{
e.Cancel = true;
}
}
和xaml:
<Window x:Class="SO_app.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:VM;assembly=VM"
xmlns:converter="clr-namespace:SO_app.Converters"
xmlns:validation="clr-namespace:SO_app.Validation"
xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
xmlns:local="clr-namespace:SO_app"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525" Closing="Window_Closing"><- here you define the handler