wslsettings: fix OOBE text truncation at 200% text scaling (#13693)
* wslsettings: fix OOBE text truncation at 200% text scaling Add text scaling factor to window resize calculation and make hero image height responsive to text scaling. Increase minimum window size for better accessibility. Fix MAS 1.4.4 compliance for OOBE dialog. * pr feedback --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Ben Hillis committed
Nov 13, 2025 at 13:52 UTC
9fad2a1b599ec374e60f4dd1e2a675e325c16427
5 files changed
+60
-11
src/windows/wslsettings/Controls/OOBEContent.xaml
+1
-1
@@ -19,7 +19,7 @@
19
20
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
21
<StackPanel
22
- Margin="32,24"
22
+ Margin="{StaticResource ContentPageMargin}"
23
VerticalAlignment="Top"
24
Orientation="Vertical"
25
Spacing="12">
src/windows/wslsettings/Controls/OOBEContent.xaml.cs
+33
-2
@@ -1,15 +1,46 @@
1
-// Copyright (c) Microsoft Corporation
1
+// Copyright (C) Microsoft Corporation. All rights reserved.
2
3
using Microsoft.UI.Xaml;
4
using Microsoft.UI.Xaml.Controls;
5
+using Windows.UI.ViewManagement;
6
7
namespace WslSettings.Controls
8
{
9
public sealed partial class OOBEContent : UserControl
10
{
11
+ // Constants for hero image height calculations
12
+ private const double BaseImageHeight = 280.0;
13
+ private const double MinimumImageHeight = 200.0;
14
+
15
+ private static readonly UISettings Settings = new UISettings();
16
+
17
public OOBEContent()
18
{
19
this.InitializeComponent();
20
+
21
+ // Set initial hero image height based on current text scaling
22
+ UpdateHeroImageHeight();
23
+
24
+ // Subscribe to text scale factor changes for dynamic updates
25
+ Settings.TextScaleFactorChanged += OnTextScaleFactorChanged;
26
+
27
+ // Ensure event cleanup when control is unloaded
28
+ this.Unloaded += (s, e) => Settings.TextScaleFactorChanged -= OnTextScaleFactorChanged;
29
+ }
30
+
31
+ private void UpdateHeroImageHeight()
32
+ {
33
+ double textScaleFactor = Settings.TextScaleFactor;
34
+
35
+ // Reduce image height when text scaling increases to preserve content space
36
+ // Use inverse relationship: as text gets larger, image gets proportionally smaller
37
+ HeroImageHeight = Math.Max(BaseImageHeight / textScaleFactor, MinimumImageHeight);
38
+ }
39
+
40
+ private void OnTextScaleFactorChanged(UISettings sender, object args)
41
+ {
42
+ // Update hero image height when text scaling changes at runtime
43
+ this.DispatcherQueue.TryEnqueue(() => UpdateHeroImageHeight());
44
}
45
46
public string Title
@@ -46,6 +77,6 @@ namespace WslSettings.Controls
77
public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register("Description", typeof(string), typeof(OOBEContent), new PropertyMetadata(default(string)));
78
public static readonly DependencyProperty HeroImageProperty = DependencyProperty.Register("HeroImage", typeof(string), typeof(OOBEContent), new PropertyMetadata(default(string)));
79
public static readonly DependencyProperty PageContentProperty = DependencyProperty.Register("PageContent", typeof(object), typeof(OOBEContent), new PropertyMetadata(new Grid()));
49
- public static readonly DependencyProperty HeroImageHeightProperty = DependencyProperty.Register("HeroImageHeight", typeof(double), typeof(OOBEContent), new PropertyMetadata(280.0));
80
+ public static readonly DependencyProperty HeroImageHeightProperty = DependencyProperty.Register("HeroImageHeight", typeof(double), typeof(OOBEContent), new PropertyMetadata(BaseImageHeight));
81
}
82
}
\ No newline at end of file
src/windows/wslsettings/LibWsl.cs
+2
-2
@@ -80,7 +80,7 @@ namespace LibWsl
80
81
internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::LibWsl.WslConfig managed)
82
{
83
-
83
+
84
return NativeToManagedMap.TryGetValue(native, out managed);
85
}
86
@@ -171,7 +171,7 @@ namespace LibWsl
171
172
internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::LibWsl.WslConfigSetting managed)
173
{
174
-
174
+
175
return NativeToManagedMap.TryGetValue(native, out managed);
176
}
177
src/windows/wslsettings/Windows/OOBEWindow.xaml
+2
-2
@@ -5,8 +5,8 @@
5
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7
xmlns:windowex="using:WinUIEx"
8
- MinWidth="480"
9
- MinHeight="480"
8
+ MinWidth="600"
9
+ MinHeight="600"
10
Closed="Window_Closed"
11
mc:Ignorable="d">
12
<Window.SystemBackdrop>
src/windows/wslsettings/Windows/OOBEWindow.xaml.cs
+22
-4
@@ -1,4 +1,4 @@
1
-// Copyright (c) Microsoft Corporation
1
+// Copyright (C) Microsoft Corporation. All rights reserved.
2
3
using Microsoft.UI.Windowing;
4
using Microsoft.UI.Xaml;
@@ -41,6 +41,7 @@ public sealed partial class OOBEWindow : WindowEx, IDisposable
41
42
// Theme change code picked from https://github.com/microsoft/WinUI-Gallery/pull/1239
43
settings.ColorValuesChanged += Settings_ColorValuesChanged; // cannot use FrameworkElement.ActualThemeChanged event
44
+ settings.TextScaleFactorChanged += Settings_TextScaleFactorChanged;
45
46
WindowManager.Get(this).IsMinimizable = false;
47
WindowManager.Get(this).IsMaximizable = false;
@@ -77,6 +78,16 @@ public sealed partial class OOBEWindow : WindowEx, IDisposable
78
});
79
}
80
81
+ // This handles text scaling changes for accessibility
82
+ private void Settings_TextScaleFactorChanged(UISettings sender, object args)
83
+ {
84
+ // This calls comes off-thread, hence we will need to dispatch it to current app's thread
85
+ dispatcherQueue.TryEnqueue(() =>
86
+ {
87
+ ResizeWindow();
88
+ });
89
+ }
90
+
91
private void Window_SizeChanged(object sender, WindowSizeChangedEventArgs args)
92
{
93
var dpi = GetDpiForWindow(hWnd);
@@ -97,9 +108,15 @@ public sealed partial class OOBEWindow : WindowEx, IDisposable
108
109
private void ResizeWindow()
110
{
100
- float scalingFactor = (float)currentDPI / DefaultDPI;
101
- int width = (int)(ExpectedWidth * scalingFactor);
102
- int height = (int)(ExpectedHeight * scalingFactor);
111
+ float dpiScalingFactor = (float)currentDPI / DefaultDPI;
112
+ float textScalingFactor = (float)settings.TextScaleFactor;
113
+
114
+ // Combine DPI scaling and text scaling for accessibility
115
+ float combinedScalingFactor = dpiScalingFactor * textScalingFactor;
116
+
117
+ int width = (int)(ExpectedWidth * combinedScalingFactor);
118
+ int height = (int)(ExpectedHeight * combinedScalingFactor);
119
+
120
SizeInt32 size;
121
size.Width = width;
122
size.Height = height;
@@ -112,6 +129,7 @@ public sealed partial class OOBEWindow : WindowEx, IDisposable
129
{
130
msgMonitor?.Dispose();
131
settings.ColorValuesChanged -= Settings_ColorValuesChanged;
132
+ settings.TextScaleFactorChanged -= Settings_TextScaleFactorChanged;
133
this.Activated -= OnWindowActivated;
134
if (this.Content is Microsoft.UI.Xaml.Controls.Page page)
135
{