diff --git a/WPF基础.sln b/WPF基础.sln index 4b4e801..a71ec82 100644 --- a/WPF基础.sln +++ b/WPF基础.sln @@ -58,6 +58,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF路由事件-2-事件路 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF路由事件-3-冒泡路由事件", "WPF路由事件-3-冒泡路由事件\WPF路由事件-3-冒泡路由事件.csproj", "{9300CA90-12F2-418C-BA84-4A774716977C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF路由事件-4-生命周期", "WPF路由事件-4-生命周期\WPF路由事件-4-生命周期.csproj", "{B5A965AA-9C4C-4EB3-8515-DF03F948EC14}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -180,5 +182,9 @@ Global {9300CA90-12F2-418C-BA84-4A774716977C}.Debug|Any CPU.Build.0 = Debug|Any CPU {9300CA90-12F2-418C-BA84-4A774716977C}.Release|Any CPU.ActiveCfg = Release|Any CPU {9300CA90-12F2-418C-BA84-4A774716977C}.Release|Any CPU.Build.0 = Release|Any CPU + {B5A965AA-9C4C-4EB3-8515-DF03F948EC14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B5A965AA-9C4C-4EB3-8515-DF03F948EC14}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B5A965AA-9C4C-4EB3-8515-DF03F948EC14}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B5A965AA-9C4C-4EB3-8515-DF03F948EC14}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/WPF路由事件-4-生命周期/App.xaml b/WPF路由事件-4-生命周期/App.xaml new file mode 100644 index 0000000..6965474 --- /dev/null +++ b/WPF路由事件-4-生命周期/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/WPF路由事件-4-生命周期/App.xaml.cs b/WPF路由事件-4-生命周期/App.xaml.cs new file mode 100644 index 0000000..1fdc28b --- /dev/null +++ b/WPF路由事件-4-生命周期/App.xaml.cs @@ -0,0 +1,12 @@ +using System.Configuration; +using System.Data; +using System.Windows; + +namespace WPF路由事件_4_生命周期; + +/// +/// Interaction logic for App.xaml +/// +public partial class App : Application +{ +} \ No newline at end of file diff --git a/WPF路由事件-4-生命周期/AssemblyInfo.cs b/WPF路由事件-4-生命周期/AssemblyInfo.cs new file mode 100644 index 0000000..4a05c7d --- /dev/null +++ b/WPF路由事件-4-生命周期/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] \ No newline at end of file diff --git a/WPF路由事件-4-生命周期/MainWindow.xaml b/WPF路由事件-4-生命周期/MainWindow.xaml new file mode 100644 index 0000000..684eec2 --- /dev/null +++ b/WPF路由事件-4-生命周期/MainWindow.xaml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/WPF路由事件-4-生命周期/MainWindow.xaml.cs b/WPF路由事件-4-生命周期/MainWindow.xaml.cs new file mode 100644 index 0000000..36859d4 --- /dev/null +++ b/WPF路由事件-4-生命周期/MainWindow.xaml.cs @@ -0,0 +1,69 @@ +using System.ComponentModel; +using System.Windows; + +namespace WPF路由事件_4_生命周期; + +/// +/// Interaction logic for MainWindow.xaml +/// +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + } + + private void FrameworkElement_OnInitialized(object? sender, EventArgs e) + { + Console.WriteLine("初始化。。。"); + ListBox.Items.Add("初始化。。。"); + } + + private void MainWindow_OnSourceInitialized(object? sender, EventArgs e) + { + Console.WriteLine("主窗口开始初始化。。。"); + ListBox.Items.Add("主窗口开始初始化。。。"); + } + + private void MainWindow_OnActivated(object? sender, EventArgs e) + { + Console.WriteLine("Activated..."); + ListBox.Items.Add("Activated..."); + } + + private void FrameworkElement_OnUnloaded(object sender, RoutedEventArgs e) + { + Console.WriteLine("加载完成。。。"); + ListBox.Items.Add("加载完成。。。"); + } + + private void FrameworkElement_OnLoaded(object sender, RoutedEventArgs e) + { + Console.WriteLine("开始加载。。。"); + ListBox.Items.Add("开始加载。。。"); + } + + private void MainWindow_OnContentRendered(object? sender, EventArgs e) + { + Console.WriteLine("主窗口---MainWindow_OnContentRendered"); + ListBox.Items.Add("主窗口---MainWindow_OnContentRendered"); + } + + private void MainWindow_OnClosing(object? sender, CancelEventArgs e) + { + Console.WriteLine("Closing..."); + ListBox.Items.Add("Closing..."); + } + + private void MainWindow_OnDeactivated(object? sender, EventArgs e) + { + Console.WriteLine("Deactivated..."); + ListBox.Items.Add("Deactivated..."); + } + + private void MainWindow_OnClosed(object? sender, EventArgs e) + { + Console.WriteLine("Closed..."); + ListBox.Items.Add("Closed..."); + } +} \ No newline at end of file diff --git a/WPF路由事件-4-生命周期/WPF路由事件-4-生命周期.csproj b/WPF路由事件-4-生命周期/WPF路由事件-4-生命周期.csproj new file mode 100644 index 0000000..b19828c --- /dev/null +++ b/WPF路由事件-4-生命周期/WPF路由事件-4-生命周期.csproj @@ -0,0 +1,12 @@ + + + + WinExe + net8.0-windows + WPF路由事件_4_生命周期 + enable + enable + true + + +