袩褉芯褋屑芯褌褉 懈褋褏芯写薪芯谐芯 泻芯写邪

淇鏍囬鏍忎富棰樺垏鎹 - 鐢↙oaded浜嬩欢纭繚FindControl鎴愬姛

纾 鏇 6 写薪械泄 薪邪蟹邪写
袪芯写懈褌械谢褜
小ommit
7614f106ae

+ 13 - 11
src/YZWater.Avalonia/Views/ViewAView.axaml.cs

@@ -1,5 +1,4 @@
 using Avalonia.Controls;
-using YZWater.Avalonia.Controls;
 
 namespace YZWater.Avalonia.Views;
 
@@ -8,15 +7,18 @@ public partial class ViewAView : UserControl
     public ViewAView()
     {
         InitializeComponent();
-        if (this.FindControl<Border>("TitleBar") is Border titleBar)
-            ThemeBrushBinding.BindTitleBar(titleBar);
-        if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
-            ThemeHelper.ThemeChanged += () => t.Foreground = ThemeHelper.HeaderText;
-        if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
-            ThemeHelper.ThemeChanged += () => s.Foreground = ThemeHelper.HeaderSubtext;
-        if (this.FindControl<Border>("StatusBar") is Border statusBar)
-            ThemeBrushBinding.BindStatusBar(statusBar);
-        if (this.FindControl<Border>("RootBorder") is Border root)
-            ThemeBrushBinding.BindContent(root);
+        Loaded += (_, _) =>
+        {
+            if (this.FindControl<Border>("TitleBar") is Border titleBar)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindTitleBar(titleBar);
+            if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
+                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
+            if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
+                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
+            if (this.FindControl<Border>("StatusBar") is Border statusBar)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindStatusBar(statusBar);
+            if (this.FindControl<Border>("RootBorder") is Border root)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindContent(root);
+        };
     }
 }

+ 13 - 11
src/YZWater.Avalonia/Views/ViewBView.axaml.cs

@@ -1,5 +1,4 @@
 using Avalonia.Controls;
-using YZWater.Avalonia.Controls;
 
 namespace YZWater.Avalonia.Views;
 
@@ -8,15 +7,18 @@ public partial class ViewBView : UserControl
     public ViewBView()
     {
         InitializeComponent();
-        if (this.FindControl<Border>("TitleBar") is Border titleBar)
-            ThemeBrushBinding.BindTitleBar(titleBar);
-        if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
-            ThemeHelper.ThemeChanged += () => t.Foreground = ThemeHelper.HeaderText;
-        if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
-            ThemeHelper.ThemeChanged += () => s.Foreground = ThemeHelper.HeaderSubtext;
-        if (this.FindControl<Border>("StatusBar") is Border statusBar)
-            ThemeBrushBinding.BindStatusBar(statusBar);
-        if (this.FindControl<Border>("RootBorder") is Border root)
-            ThemeBrushBinding.BindContent(root);
+        Loaded += (_, _) =>
+        {
+            if (this.FindControl<Border>("TitleBar") is Border titleBar)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindTitleBar(titleBar);
+            if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
+                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
+            if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
+                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
+            if (this.FindControl<Border>("StatusBar") is Border statusBar)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindStatusBar(statusBar);
+            if (this.FindControl<Border>("RootBorder") is Border root)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindContent(root);
+        };
     }
 }

+ 13 - 11
src/YZWater.Avalonia/Views/ViewCView.axaml.cs

@@ -1,5 +1,4 @@
 using Avalonia.Controls;
-using YZWater.Avalonia.Controls;
 
 namespace YZWater.Avalonia.Views;
 
@@ -8,15 +7,18 @@ public partial class ViewCView : UserControl
     public ViewCView()
     {
         InitializeComponent();
-        if (this.FindControl<Border>("TitleBar") is Border titleBar)
-            ThemeBrushBinding.BindTitleBar(titleBar);
-        if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
-            ThemeHelper.ThemeChanged += () => t.Foreground = ThemeHelper.HeaderText;
-        if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
-            ThemeHelper.ThemeChanged += () => s.Foreground = ThemeHelper.HeaderSubtext;
-        if (this.FindControl<Border>("StatusBar") is Border statusBar)
-            ThemeBrushBinding.BindStatusBar(statusBar);
-        if (this.FindControl<Border>("RootBorder") is Border root)
-            ThemeBrushBinding.BindContent(root);
+        Loaded += (_, _) =>
+        {
+            if (this.FindControl<Border>("TitleBar") is Border titleBar)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindTitleBar(titleBar);
+            if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
+                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
+            if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
+                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
+            if (this.FindControl<Border>("StatusBar") is Border statusBar)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindStatusBar(statusBar);
+            if (this.FindControl<Border>("RootBorder") is Border root)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindContent(root);
+        };
     }
 }

+ 13 - 11
src/YZWater.Avalonia/Views/ViewDView.axaml.cs

@@ -1,5 +1,4 @@
 using Avalonia.Controls;
-using YZWater.Avalonia.Controls;
 
 namespace YZWater.Avalonia.Views;
 
@@ -8,15 +7,18 @@ public partial class ViewDView : UserControl
     public ViewDView()
     {
         InitializeComponent();
-        if (this.FindControl<Border>("TitleBar") is Border titleBar)
-            ThemeBrushBinding.BindTitleBar(titleBar);
-        if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
-            ThemeHelper.ThemeChanged += () => t.Foreground = ThemeHelper.HeaderText;
-        if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
-            ThemeHelper.ThemeChanged += () => s.Foreground = ThemeHelper.HeaderSubtext;
-        if (this.FindControl<Border>("StatusBar") is Border statusBar)
-            ThemeBrushBinding.BindStatusBar(statusBar);
-        if (this.FindControl<Border>("RootBorder") is Border root)
-            ThemeBrushBinding.BindContent(root);
+        Loaded += (_, _) =>
+        {
+            if (this.FindControl<Border>("TitleBar") is Border titleBar)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindTitleBar(titleBar);
+            if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
+                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
+            if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
+                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
+            if (this.FindControl<Border>("StatusBar") is Border statusBar)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindStatusBar(statusBar);
+            if (this.FindControl<Border>("RootBorder") is Border root)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindContent(root);
+        };
     }
 }

+ 13 - 11
src/YZWater.Avalonia/Views/ViewEView.axaml.cs

@@ -1,5 +1,4 @@
 using Avalonia.Controls;
-using YZWater.Avalonia.Controls;
 
 namespace YZWater.Avalonia.Views;
 
@@ -8,15 +7,18 @@ public partial class ViewEView : UserControl
     public ViewEView()
     {
         InitializeComponent();
-        if (this.FindControl<Border>("TitleBar") is Border titleBar)
-            ThemeBrushBinding.BindTitleBar(titleBar);
-        if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
-            ThemeHelper.ThemeChanged += () => t.Foreground = ThemeHelper.HeaderText;
-        if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
-            ThemeHelper.ThemeChanged += () => s.Foreground = ThemeHelper.HeaderSubtext;
-        if (this.FindControl<Border>("StatusBar") is Border statusBar)
-            ThemeBrushBinding.BindStatusBar(statusBar);
-        if (this.FindControl<Border>("RootBorder") is Border root)
-            ThemeBrushBinding.BindContent(root);
+        Loaded += (_, _) =>
+        {
+            if (this.FindControl<Border>("TitleBar") is Border titleBar)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindTitleBar(titleBar);
+            if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
+                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
+            if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
+                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
+            if (this.FindControl<Border>("StatusBar") is Border statusBar)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindStatusBar(statusBar);
+            if (this.FindControl<Border>("RootBorder") is Border root)
+                YZWater.Avalonia.Controls.ThemeBrushBinding.BindContent(root);
+        };
     }
 }