From 7368afd24c8050ff97b6389c943097b8d817ef36 Mon Sep 17 00:00:00 2001
From: Bunny <1319900154@qq.com>
Date: Wed, 1 Jan 2025 21:56:07 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20WPF=E8=B7=AF=E7=94=B1=E4=BA=8B=E4=BB=B6?=
=?UTF-8?q?-4-=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
WPF基础.sln | 6 ++
WPF路由事件-4-生命周期/App.xaml | 9 +++
WPF路由事件-4-生命周期/App.xaml.cs | 12 ++++
WPF路由事件-4-生命周期/AssemblyInfo.cs | 10 +++
WPF路由事件-4-生命周期/MainWindow.xaml | 14 ++++
WPF路由事件-4-生命周期/MainWindow.xaml.cs | 69 +++++++++++++++++++
.../WPF路由事件-4-生命周期.csproj | 12 ++++
7 files changed, 132 insertions(+)
create mode 100644 WPF路由事件-4-生命周期/App.xaml
create mode 100644 WPF路由事件-4-生命周期/App.xaml.cs
create mode 100644 WPF路由事件-4-生命周期/AssemblyInfo.cs
create mode 100644 WPF路由事件-4-生命周期/MainWindow.xaml
create mode 100644 WPF路由事件-4-生命周期/MainWindow.xaml.cs
create mode 100644 WPF路由事件-4-生命周期/WPF路由事件-4-生命周期.csproj
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
+
+
+