Skip to content

Commit 52d63a4

Browse files
Update to Windows App SDK 1.4.230913002 & WinUIEx 2.3.2 (#4712)
1 parent 4a8b81a commit 52d63a4

4 files changed

Lines changed: 20 additions & 51 deletions

File tree

code/TemplateStudioForWinUICs/Templates/Proj/Default/.template.config/template.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"ts.outputToParent": "true",
2121
"ts.version": "1.0.0",
2222
"ts.displayOrder": "0",
23-
"ts.licenses": "[Microsoft.WindowsAppSDK](https://www.nuget.org/packages/Microsoft.WindowsAppSDK/1.3.230331000/License)|[WinUIEx](https://licenses.nuget.org/MIT)"
23+
"ts.licenses": "[Microsoft.WindowsAppSDK](https://www.nuget.org/packages/Microsoft.WindowsAppSDK/1.4.231008000/License)|[WinUIEx](https://licenses.nuget.org/MIT)"
2424
},
2525
"sourceName": "Param_ProjectName",
2626
"preferNameDirectory": true,
@@ -87,7 +87,7 @@
8787
"actionId": "0B814718-16A3-4F7F-89F1-69C0F9170EAD",
8888
"args": {
8989
"packageId": "Microsoft.WindowsAppSDK",
90-
"version": "1.3.230502000",
90+
"version": "1.4.231008000",
9191
"projectPath": "Param_ProjectName\\Param_ProjectName.csproj"
9292
},
9393
"continueOnError": true
@@ -98,7 +98,7 @@
9898
"actionId": "0B814718-16A3-4F7F-89F1-69C0F9170EAD",
9999
"args": {
100100
"packageId": "WinUIEx",
101-
"version": "2.2",
101+
"version": "2.3.2",
102102
"projectPath": "Param_ProjectName\\Param_ProjectName.csproj"
103103
},
104104
"continueOnError": true

code/TemplateStudioForWinUICs/Templates/Proj/Default/Param_ProjectName/Helpers/TitleBarHelper.cs

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -39,50 +39,35 @@ public static void UpdateTitleBar(ElementTheme theme)
3939
theme = Application.Current.RequestedTheme == ApplicationTheme.Light ? ElementTheme.Light : ElementTheme.Dark;
4040
}
4141

42-
Application.Current.Resources["WindowCaptionForeground"] = theme switch
42+
App.MainWindow.AppWindow.TitleBar.ButtonForegroundColor = theme switch
4343
{
44-
ElementTheme.Dark => new SolidColorBrush(Colors.White),
45-
ElementTheme.Light => new SolidColorBrush(Colors.Black),
46-
_ => new SolidColorBrush(Colors.Transparent)
44+
ElementTheme.Dark => Colors.White,
45+
ElementTheme.Light => Colors.Black,
46+
_ => Colors.Transparent
4747
};
4848

49-
Application.Current.Resources["WindowCaptionForegroundDisabled"] = theme switch
49+
App.MainWindow.AppWindow.TitleBar.ButtonHoverForegroundColor = theme switch
5050
{
51-
ElementTheme.Dark => new SolidColorBrush(Color.FromArgb(0x66, 0xFF, 0xFF, 0xFF)),
52-
ElementTheme.Light => new SolidColorBrush(Color.FromArgb(0x66, 0x00, 0x00, 0x00)),
53-
_ => new SolidColorBrush(Colors.Transparent)
51+
ElementTheme.Dark => Colors.White,
52+
ElementTheme.Light => Colors.Black,
53+
_ => Colors.Transparent
5454
};
5555

56-
Application.Current.Resources["WindowCaptionButtonBackgroundPointerOver"] = theme switch
56+
App.MainWindow.AppWindow.TitleBar.ButtonHoverBackgroundColor = theme switch
5757
{
58-
ElementTheme.Dark => new SolidColorBrush(Color.FromArgb(0x33, 0xFF, 0xFF, 0xFF)),
59-
ElementTheme.Light => new SolidColorBrush(Color.FromArgb(0x33, 0x00, 0x00, 0x00)),
60-
_ => new SolidColorBrush(Colors.Transparent)
58+
ElementTheme.Dark => Color.FromArgb(0x33, 0xFF, 0xFF, 0xFF),
59+
ElementTheme.Light => Color.FromArgb(0x33, 0x00, 0x00, 0x00),
60+
_ => Colors.Transparent
6161
};
6262

63-
Application.Current.Resources["WindowCaptionButtonBackgroundPressed"] = theme switch
63+
App.MainWindow.AppWindow.TitleBar.ButtonPressedBackgroundColor = theme switch
6464
{
65-
ElementTheme.Dark => new SolidColorBrush(Color.FromArgb(0x66, 0xFF, 0xFF, 0xFF)),
66-
ElementTheme.Light => new SolidColorBrush(Color.FromArgb(0x66, 0x00, 0x00, 0x00)),
67-
_ => new SolidColorBrush(Colors.Transparent)
65+
ElementTheme.Dark => Color.FromArgb(0x66, 0xFF, 0xFF, 0xFF),
66+
ElementTheme.Light => Color.FromArgb(0x66, 0x00, 0x00, 0x00),
67+
_ => Colors.Transparent
6868
};
6969

70-
Application.Current.Resources["WindowCaptionButtonStrokePointerOver"] = theme switch
71-
{
72-
ElementTheme.Dark => new SolidColorBrush(Colors.White),
73-
ElementTheme.Light => new SolidColorBrush(Colors.Black),
74-
_ => new SolidColorBrush(Colors.Transparent)
75-
};
76-
77-
Application.Current.Resources["WindowCaptionButtonStrokePressed"] = theme switch
78-
{
79-
ElementTheme.Dark => new SolidColorBrush(Colors.White),
80-
ElementTheme.Light => new SolidColorBrush(Colors.Black),
81-
_ => new SolidColorBrush(Colors.Transparent)
82-
};
83-
84-
Application.Current.Resources["WindowCaptionBackground"] = new SolidColorBrush(Colors.Transparent);
85-
Application.Current.Resources["WindowCaptionBackgroundDisabled"] = new SolidColorBrush(Colors.Transparent);
70+
App.MainWindow.AppWindow.TitleBar.BackgroundColor = Colors.Transparent;
8671

8772
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(App.MainWindow);
8873
if (hwnd == GetActiveWindow())
@@ -100,19 +85,9 @@ public static void UpdateTitleBar(ElementTheme theme)
10085

10186
public static void ApplySystemThemeToCaptionButtons()
10287
{
103-
var res = Application.Current.Resources;
10488
var frame = App.AppTitlebar as FrameworkElement;
10589
if (frame != null)
10690
{
107-
if (frame.ActualTheme == ElementTheme.Dark)
108-
{
109-
res["WindowCaptionForeground"] = Colors.White;
110-
}
111-
else
112-
{
113-
res["WindowCaptionForeground"] = Colors.Black;
114-
}
115-
11691
UpdateTitleBar(frame.ActualTheme);
11792
}
11893
}

code/TemplateStudioForWinUICs/Templates/_comp/MT/Project.MenuBar/Views/ShellPage.xaml.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ private void OnLoaded(object sender, RoutedEventArgs e)
4242

4343
private void MainWindow_Activated(object sender, WindowActivatedEventArgs args)
4444
{
45-
var resource = args.WindowActivationState == WindowActivationState.Deactivated ? "WindowCaptionForegroundDisabled" : "WindowCaptionForeground";
46-
47-
AppTitleBarText.Foreground = (SolidColorBrush)App.Current.Resources[resource];
4845
App.AppTitlebar = AppTitleBarText as UIElement;
4946
}
5047

code/TemplateStudioForWinUICs/Templates/_comp/MT/Project.NavView/Views/ShellPage.xaml.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ private void OnLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
4444

4545
private void MainWindow_Activated(object sender, WindowActivatedEventArgs args)
4646
{
47-
var resource = args.WindowActivationState == WindowActivationState.Deactivated ? "WindowCaptionForegroundDisabled" : "WindowCaptionForeground";
48-
49-
AppTitleBarText.Foreground = (SolidColorBrush)App.Current.Resources[resource];
5047
App.AppTitlebar = AppTitleBarText as UIElement;
5148
}
5249

0 commit comments

Comments
 (0)