|
|
@@ -9,13 +9,19 @@ public partial class ViewAView : UserControl
|
|
|
public ViewAView()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
- ThemeHelper.ThemeChanged += ApplyTheme;
|
|
|
- ApplyTheme();
|
|
|
+ AttachedToVisualTree += (_, _) =>
|
|
|
+ {
|
|
|
+ ApplyTheme();
|
|
|
+ ThemeHelper.ThemeChanged += ApplyTheme;
|
|
|
+ };
|
|
|
+ DetachedFromVisualTree += (_, _) =>
|
|
|
+ {
|
|
|
+ ThemeHelper.ThemeChanged -= ApplyTheme;
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
private void ApplyTheme()
|
|
|
{
|
|
|
- // 閬嶅巻瑙嗚鏍戞壘鍒板懡鍚嶅厓绱
|
|
|
foreach (var visual in this.GetVisualDescendants())
|
|
|
{
|
|
|
if (visual is Border border && border.Name == "TitleBar")
|