我試圖同時打開一個新的關閉窗口,但this.close()不被系統識別this.close()不能被識別爲法
private void Insert_Data_Click(object sender, RoutedEventArgs e)
{
MainWindow DataWindow = new MainWindow();
DataWindow.Show();
this.Close();
}
這是類聲明
public partial class Home_autismo : MetroWindow
和包含的庫
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
任何想法,爲什麼this.Close()不承認?
你試過'Application.Exit()'? – RandomStranger
你能詳細說明一下嗎?它在運行時不起作用,甚至不能編譯?我的應用程序中有完全相同的代碼,這很簡單。 'Application.Exit()'在嘗試切換窗口時退出不方便的應用程序。 – SilentStorm
還要確保你的xaml文件不是一個用戶控件或頁面,而是以''
SilentStorm