wslsettings: ensure selected setting is auto-expanded and selected (#13689)

* wslsettings: ensure selected setting is auto-selected Implement keyboard focus management for SettingsExpander controls across settings pages. This resolves an accessibility issue reported internally. * add asserts --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

Ben Hillis committed Nov 18, 2025 at 08:19 UTC 7226b05100b20955692ec83914644c07d035047f
11 files changed +112 -22
src/windows/wslsettings/Helpers/RuntimeHelper.cs
+37
@@ -1,7 +1,9 @@
1 // Copyright (C) Microsoft Corporation. All rights reserved.
2
3 +using CommunityToolkit.WinUI.Controls;
4 using Microsoft.UI.Xaml.Controls;
5 using Microsoft.UI.Xaml.Input;
6 +using System.Diagnostics;
7 using System.Reflection;
8 using System.Runtime.InteropServices;
9 using System.Text;
@@ -47,4 +49,39 @@ public class RuntimeHelper
49 FindNextElementOptions fneo = new() { SearchRoot = button.XamlRoot.Content };
50 FocusManager.TryMoveFocus(FocusNavigationDirection.Previous, fneo);
51 }
52 +
53 + public static void SetupSettingsExpanderFocusManagement(Microsoft.UI.Xaml.FrameworkElement expander, Microsoft.UI.Xaml.Controls.Control firstFocusableElement)
54 + {
55 + if (expander is CommunityToolkit.WinUI.Controls.SettingsExpander settingsExpander)
56 + {
57 + settingsExpander.RegisterPropertyChangedCallback(CommunityToolkit.WinUI.Controls.SettingsExpander.IsExpandedProperty, (sender, dp) =>
58 + {
59 + if (sender is CommunityToolkit.WinUI.Controls.SettingsExpander se && se.IsExpanded)
60 + {
61 + System.EventHandler<object>? layoutHandler = null;
62 + layoutHandler = (s, e) =>
63 + {
64 + se.LayoutUpdated -= layoutHandler;
65 + firstFocusableElement.Focus(Microsoft.UI.Xaml.FocusState.Keyboard);
66 + };
67 +
68 + se.LayoutUpdated += layoutHandler;
69 + }
70 + });
71 + }
72 + }
73 +
74 + public static void SetupExpanderFocusManagementByName(Microsoft.UI.Xaml.FrameworkElement parent, string expanderName, string textBoxName)
75 + {
76 + var expander = parent.FindName(expanderName) as Microsoft.UI.Xaml.FrameworkElement;
77 + var textBox = parent.FindName(textBoxName) as Microsoft.UI.Xaml.Controls.Control;
78 +
79 + Debug.Assert(expander != null, $"Expander '{expanderName}' not found");
80 + Debug.Assert(textBox != null, $"TextBox '{textBoxName}' not found");
81 +
82 + if (expander != null && textBox != null)
83 + {
84 + SetupSettingsExpanderFocusManagement(expander, textBox);
85 + }
86 + }
87 }
\ No newline at end of file
src/windows/wslsettings/Views/Settings/DeveloperPage.xaml
+6 -6
@@ -25,12 +25,12 @@
25 <ctControls:SettingsCard x:Uid="Settings_HWPerfCounters">
26 <ToggleSwitch x:Uid="Settings_HWPerfCountersToggleSwitch" HorizontalAlignment="Right" MinWidth="0" IsOn="{x:Bind ViewModel.IsOnHWPerfCounters, Mode=TwoWay}"/>
27 </ctControls:SettingsCard>
28 - <ctControls:SettingsExpander x:Uid="Settings_CustomKernelPath">
28 + <ctControls:SettingsExpander x:Name="CustomKernelPathExpander" x:Uid="Settings_CustomKernelPath">
29 <TextBlock Style="{StaticResource TextBlockFilePathStyle}" Text="{x:Bind ViewModel.CustomKernelPath, Mode=OneWay}"/>
30 <ctControls:SettingsExpander.Items>
31 <ctControls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left" Margin="{StaticResource SettingsExpanderItemMargin}">
32 <StackPanel Orientation="Horizontal">
33 - <TextBox x:Uid="Settings_CustomKernelPathTextBox" Style="{StaticResource TextBoxFilePathStyle}" Margin="{StaticResource InputControlSpacingMargin}"
33 + <TextBox x:Name="CustomKernelPathTextBox" x:Uid="Settings_CustomKernelPathTextBox" Style="{StaticResource TextBoxFilePathStyle}" Margin="{StaticResource InputControlSpacingMargin}"
34 Text="{x:Bind ViewModel.CustomKernelPath, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"/>
35 <Button x:Uid="Settings_CustomKernelPathBrowseButton" Style="{StaticResource ButtonSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
36 Click="CustomKernelPath_Click"/>
@@ -38,12 +38,12 @@
38 </ctControls:SettingsCard>
39 </ctControls:SettingsExpander.Items>
40 </ctControls:SettingsExpander>
41 - <ctControls:SettingsExpander x:Uid="Settings_CustomKernelModulesPath">
41 + <ctControls:SettingsExpander x:Name="CustomKernelModulesPathExpander" x:Uid="Settings_CustomKernelModulesPath">
42 <TextBlock Style="{StaticResource TextBlockFilePathStyle}" Text="{x:Bind ViewModel.CustomKernelModulesPath, Mode=OneWay}"/>
43 <ctControls:SettingsExpander.Items>
44 <ctControls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left" Margin="{StaticResource SettingsExpanderItemMargin}">
45 <StackPanel Orientation="Horizontal">
46 - <TextBox x:Uid="Settings_CustomKernelModulesPathTextBox" Style="{StaticResource TextBoxFilePathStyle}" Margin="{StaticResource InputControlSpacingMargin}"
46 + <TextBox x:Name="CustomKernelModulesPathTextBox" x:Uid="Settings_CustomKernelModulesPathTextBox" Style="{StaticResource TextBoxFilePathStyle}" Margin="{StaticResource InputControlSpacingMargin}"
47 Text="{x:Bind ViewModel.CustomKernelModulesPath, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"/>
48 <Button x:Uid="Settings_CustomKernelModulesPathBrowseButton" Style="{StaticResource ButtonSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
49 Click="CustomKernelModulesPath_Click"/>
@@ -51,7 +51,7 @@
51 </ctControls:SettingsCard>
52 </ctControls:SettingsExpander.Items>
53 </ctControls:SettingsExpander>
54 - <ctControls:SettingsExpander x:Uid="Settings_CustomSystemDistroPath">
54 + <ctControls:SettingsExpander x:Name="CustomSystemDistroPathExpander" x:Uid="Settings_CustomSystemDistroPath">
55 <ctControls:SettingsExpander.Description>
56 <controls:HyperlinkTextBlock x:Uid="Settings_CustomSystemDistroPathDescription"/>
57 </ctControls:SettingsExpander.Description>
@@ -59,7 +59,7 @@
59 <ctControls:SettingsExpander.Items>
60 <ctControls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left" Margin="{StaticResource SettingsExpanderItemMargin}">
61 <StackPanel Orientation="Horizontal">
62 - <TextBox x:Uid="Settings_CustomSystemDistroPathTextBox" Style="{StaticResource TextBoxFilePathStyle}" Margin="{StaticResource InputControlSpacingMargin}"
62 + <TextBox x:Name="CustomSystemDistroPathTextBox" x:Uid="Settings_CustomSystemDistroPathTextBox" Style="{StaticResource TextBoxFilePathStyle}" Margin="{StaticResource InputControlSpacingMargin}"
63 Text="{x:Bind ViewModel.CustomSystemDistroPath, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"/>
64 <Button x:Uid="Settings_CustomSystemDistroPathBrowseButton" Style="{StaticResource ButtonSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
65 Click="CustomSystemDistroPath_Click"/>
src/windows/wslsettings/Views/Settings/DeveloperPage.xaml.cs
+9
@@ -27,6 +27,15 @@ public sealed partial class DeveloperPage : Page
27 FrameworkElementAutomationPeer.FromElement(Settings_ErrorTryAgainLater).RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
28 }
29 });
30 +
31 + this.Loaded += OnPageLoaded;
32 + }
33 +
34 + private void OnPageLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
35 + {
36 + RuntimeHelper.SetupExpanderFocusManagementByName(this, "CustomKernelPathExpander", "CustomKernelPathTextBox");
37 + RuntimeHelper.SetupExpanderFocusManagementByName(this, "CustomKernelModulesPathExpander", "CustomKernelModulesPathTextBox");
38 + RuntimeHelper.SetupExpanderFocusManagementByName(this, "CustomSystemDistroPathExpander", "CustomSystemDistroPathTextBox");
39 }
40
41 override protected void OnNavigatedFrom(NavigationEventArgs e)
src/windows/wslsettings/Views/Settings/FileSystemPage.xaml
+2 -2
@@ -18,12 +18,12 @@
18 <ScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Auto"
19 Visibility="{x:Bind ViewModel.SettingsContentVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BooleanToVisibilityConverter}}">
20 <StackPanel Spacing="{StaticResource SettingsCardSpacing}">
21 - <ctControls:SettingsExpander x:Uid="Settings_DefaultVHDSize">
21 + <ctControls:SettingsExpander x:Name="DefaultVHDSizeExpander" x:Uid="Settings_DefaultVHDSize">
22 <TextBlock Style="{StaticResource TextBlockSettingStyle}" Text="{x:Bind ViewModel.DefaultVHDSize, Mode=OneWay, Converter={StaticResource MegabyteStringConverter}}"/>
23 <ctControls:SettingsExpander.Items>
24 <ctControls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left" Margin="{StaticResource SettingsExpanderItemMargin}">
25 <StackPanel Orientation="Horizontal">
26 - <TextBox x:Uid="Settings_DefaultVHDSizeTextBox" Style="{StaticResource TextBoxSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
26 + <TextBox x:Name="DefaultVHDSizeTextBox" x:Uid="Settings_DefaultVHDSizeTextBox" Style="{StaticResource TextBoxSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
27 Text="{x:Bind ViewModel.DefaultVHDSize, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource MegabyteNumberConverter}}" TextChanged="DefaultVHDSizeTextBox_TextChanged"/>
28 <Button x:Uid="Settings_DefaultVHDSizeResetButton" Style="{StaticResource ButtonSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
29 Command="{x:Bind ViewModel.DefaultVHDSize_ResetCommand}" IsEnabled="{x:Bind ViewModel.DefaultVHDSize_ResetEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
src/windows/wslsettings/Views/Settings/FileSystemPage.xaml.cs
+18
@@ -1,8 +1,10 @@
1 // Copyright (C) Microsoft Corporation. All rights reserved.
2
3 +using CommunityToolkit.WinUI.Controls;
4 using Microsoft.UI.Xaml.Automation.Peers;
5 using Microsoft.UI.Xaml.Controls;
6 using Microsoft.UI.Xaml.Navigation;
7 +using System.Diagnostics;
8 using WslSettings.Contracts.Services;
9 using WslSettings.ViewModels.Settings;
10
@@ -26,6 +28,8 @@ public sealed partial class FileSystemPage : Page
28 FrameworkElementAutomationPeer.FromElement(Settings_ErrorTryAgainLater).RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
29 }
30 });
31 +
32 + this.Loaded += OnPageLoaded;
33 }
34
35 override protected void OnNavigatedFrom(NavigationEventArgs e)
@@ -53,4 +57,18 @@ public sealed partial class FileSystemPage : Page
57 TextBox? textBox = sender as TextBox;
58 ViewModel.SetDefaultVHDSize_ResetEnabled(textBox!.Text);
59 }
60 +
61 + private void OnPageLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
62 + {
63 + var expander = this.FindName("DefaultVHDSizeExpander") as SettingsExpander;
64 + var textBox = this.FindName("DefaultVHDSizeTextBox") as TextBox;
65 +
66 + Debug.Assert(expander != null, "DefaultVHDSizeExpander not found");
67 + Debug.Assert(textBox != null, "DefaultVHDSizeTextBox not found");
68 +
69 + if (expander != null && textBox != null)
70 + {
71 + RuntimeHelper.SetupSettingsExpanderFocusManagement(expander, textBox);
72 + }
73 + }
74 }
src/windows/wslsettings/Views/Settings/MemAndProcPage.xaml
+8 -8
@@ -18,12 +18,12 @@
18 <ScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Auto"
19 Visibility="{x:Bind ViewModel.SettingsContentVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BooleanToVisibilityConverter}}">
20 <StackPanel Spacing="{StaticResource SettingsCardSpacing}">
21 - <ctControls:SettingsExpander x:Uid="Settings_ProcCount">
21 + <ctControls:SettingsExpander x:Name="ProcCountExpander" x:Uid="Settings_ProcCount">
22 <TextBlock Style="{StaticResource TextBlockSettingStyle}" Text="{x:Bind ViewModel.ProcCount, Mode=OneWay}"/>
23 <ctControls:SettingsExpander.Items>
24 <ctControls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left" Margin="{StaticResource SettingsExpanderItemMargin}">
25 <StackPanel Orientation="Horizontal">
26 - <TextBox x:Uid="Settings_ProcCountTextBox" Style="{StaticResource TextBoxSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
26 + <TextBox x:Name="ProcCountTextBox" x:Uid="Settings_ProcCountTextBox" Style="{StaticResource TextBoxSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
27 Text="{x:Bind ViewModel.ProcCount, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextChanged="ProcCountTextBox_TextChanged"/>
28 <Button x:Uid="Settings_ProcCountResetButton" Style="{StaticResource ButtonSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
29 Command="{x:Bind ViewModel.ProcCount_ResetCommand}" IsEnabled="{x:Bind ViewModel.ProcCount_ResetEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
@@ -32,12 +32,12 @@
32 </ctControls:SettingsCard>
33 </ctControls:SettingsExpander.Items>
34 </ctControls:SettingsExpander>
35 - <ctControls:SettingsExpander x:Uid="Settings_MemorySize">
35 + <ctControls:SettingsExpander x:Name="MemorySizeExpander" x:Uid="Settings_MemorySize">
36 <TextBlock Style="{StaticResource TextBlockSettingStyle}" Text="{x:Bind ViewModel.MemorySize, Mode=OneWay, Converter={StaticResource MegabyteStringConverter}}"/>
37 <ctControls:SettingsExpander.Items>
38 <ctControls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left" Margin="{StaticResource SettingsExpanderItemMargin}">
39 <StackPanel Orientation="Horizontal">
40 - <TextBox x:Uid="Settings_MemorySizeTextBox" Style="{StaticResource TextBoxSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
40 + <TextBox x:Name="MemorySizeTextBox" x:Uid="Settings_MemorySizeTextBox" Style="{StaticResource TextBoxSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
41 Text="{x:Bind ViewModel.MemorySize, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource MegabyteNumberConverter}}" TextChanged="MemorySizeTextBox_TextChanged"/>
42 <Button x:Uid="Settings_MemorySizeResetButton" Style="{StaticResource ButtonSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
43 Command="{x:Bind ViewModel.MemorySize_ResetCommand}" IsEnabled="{x:Bind ViewModel.MemorySize_ResetEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
@@ -46,12 +46,12 @@
46 </ctControls:SettingsCard>
47 </ctControls:SettingsExpander.Items>
48 </ctControls:SettingsExpander>
49 - <ctControls:SettingsExpander x:Uid="Settings_SwapSize">
49 + <ctControls:SettingsExpander x:Name="SwapSizeExpander" x:Uid="Settings_SwapSize">
50 <TextBlock Style="{StaticResource TextBlockSettingStyle}" Text="{x:Bind ViewModel.SwapSize, Mode=OneWay, Converter={StaticResource MegabyteStringConverter}}"/>
51 <ctControls:SettingsExpander.Items>
52 <ctControls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left" Margin="{StaticResource SettingsExpanderItemMargin}">
53 <StackPanel Orientation="Horizontal">
54 - <TextBox x:Uid="Settings_SwapSizeTextBox" Style="{StaticResource TextBoxSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
54 + <TextBox x:Name="SwapSizeTextBox" x:Uid="Settings_SwapSizeTextBox" Style="{StaticResource TextBoxSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
55 Text="{x:Bind ViewModel.SwapSize, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource MegabyteNumberConverter}}" TextChanged="SwapSizeTextBox_TextChanged"/>
56 <Button x:Uid="Settings_SwapSizeResetButton" Style="{StaticResource ButtonSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
57 Command="{x:Bind ViewModel.SwapSize_ResetCommand}" IsEnabled="{x:Bind ViewModel.SwapSize_ResetEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
@@ -60,12 +60,12 @@
60 </ctControls:SettingsCard>
61 </ctControls:SettingsExpander.Items>
62 </ctControls:SettingsExpander>
63 - <ctControls:SettingsExpander x:Uid="Settings_SwapFilePath">
63 + <ctControls:SettingsExpander x:Name="SwapFilePathExpander" x:Uid="Settings_SwapFilePath">
64 <TextBlock Style="{StaticResource TextBlockFilePathStyle}" Text="{x:Bind ViewModel.SwapFilePath, Mode=OneWay}"/>
65 <ctControls:SettingsExpander.Items>
66 <ctControls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left" Margin="{StaticResource SettingsExpanderItemMargin}">
67 <StackPanel Orientation="Horizontal">
68 - <TextBox x:Uid="Settings_SwapFilePathTextBox" Style="{StaticResource TextBoxFilePathStyle}" Margin="{StaticResource InputControlSpacingMargin}"
68 + <TextBox x:Name="SwapFilePathTextBox" x:Uid="Settings_SwapFilePathTextBox" Style="{StaticResource TextBoxFilePathStyle}" Margin="{StaticResource InputControlSpacingMargin}"
69 Text="{x:Bind ViewModel.SwapFilePath, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"/>
70 <Button x:Uid="Settings_SwapFilePathBrowseButton" Style="{StaticResource ButtonSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
71 Click="SwapFilePath_Click"/>
src/windows/wslsettings/Views/Settings/MemAndProcPage.xaml.cs
+10
@@ -27,6 +27,16 @@ public sealed partial class MemAndProcPage : Page
27 FrameworkElementAutomationPeer.FromElement(Settings_ErrorTryAgainLater).RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
28 }
29 });
30 +
31 + this.Loaded += OnPageLoaded;
32 + }
33 +
34 + private void OnPageLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
35 + {
36 + RuntimeHelper.SetupExpanderFocusManagementByName(this, "ProcCountExpander", "ProcCountTextBox");
37 + RuntimeHelper.SetupExpanderFocusManagementByName(this, "MemorySizeExpander", "MemorySizeTextBox");
38 + RuntimeHelper.SetupExpanderFocusManagementByName(this, "SwapSizeExpander", "SwapSizeTextBox");
39 + RuntimeHelper.SetupExpanderFocusManagementByName(this, "SwapFilePathExpander", "SwapFilePathTextBox");
40 }
41
42 override protected void OnNavigatedFrom(NavigationEventArgs e)
src/windows/wslsettings/Views/Settings/NetworkingPage.xaml
+4 -4
@@ -25,12 +25,12 @@
25 <ctControls:SettingsCard x:Uid="Settings_HyperVFirewall">
26 <ToggleSwitch x:Uid="Settings_HyperVFirewallToggleSwitch" HorizontalAlignment="Right" MinWidth="0" IsOn="{x:Bind ViewModel.IsOnHyperVFirewall, Mode=TwoWay}"/>
27 </ctControls:SettingsCard>
28 - <ctControls:SettingsExpander x:Uid="Settings_IgnoredPorts">
28 + <ctControls:SettingsExpander x:Name="IgnoredPortsExpander" x:Uid="Settings_IgnoredPorts">
29 <TextBlock Style="{StaticResource TextBlockSettingStyle}" Text="{x:Bind ViewModel.IgnoredPorts, Mode=OneWay}"/>
30 <ctControls:SettingsExpander.Items>
31 <ctControls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left" Margin="{StaticResource SettingsExpanderItemMargin}">
32 <StackPanel Orientation="Horizontal">
33 - <TextBox x:Uid="Settings_IgnoredPortsTextBox" Style="{StaticResource TextBoxSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
33 + <TextBox x:Name="IgnoredPortsTextBox" x:Uid="Settings_IgnoredPortsTextBox" Style="{StaticResource TextBoxSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
34 Text="{x:Bind ViewModel.IgnoredPorts, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"/>
35 <Button x:Uid="Settings_IgnoredPortsResetButton" Style="{StaticResource ButtonSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
36 Command="{x:Bind ViewModel.IgnoredPorts_ResetCommand}" IsEnabled="{x:Bind ViewModel.IgnoredPorts_ResetEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
@@ -48,12 +48,12 @@
48 <ctControls:SettingsCard x:Uid="Settings_AutoProxy">
49 <ToggleSwitch x:Uid="Settings_AutoProxyToggleSwitch" HorizontalAlignment="Right" MinWidth="0" IsOn="{x:Bind ViewModel.IsOnAutoProxy, Mode=TwoWay}"/>
50 </ctControls:SettingsCard>
51 - <ctControls:SettingsExpander x:Uid="Settings_InitialAutoProxyTimeout">
51 + <ctControls:SettingsExpander x:Name="InitialAutoProxyTimeoutExpander" x:Uid="Settings_InitialAutoProxyTimeout">
52 <TextBlock Style="{StaticResource TextBlockSettingStyle}" Text="{x:Bind ViewModel.InitialAutoProxyTimeout, Mode=OneWay, Converter={StaticResource MillisecondsStringConverter}}"/>
53 <ctControls:SettingsExpander.Items>
54 <ctControls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left" Margin="{StaticResource SettingsExpanderItemMargin}">
55 <StackPanel Orientation="Horizontal">
56 - <TextBox x:Uid="Settings_InitialAutoProxyTimeoutTextBox" Style="{StaticResource TextBoxSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
56 + <TextBox x:Name="InitialAutoProxyTimeoutTextBox" x:Uid="Settings_InitialAutoProxyTimeoutTextBox" Style="{StaticResource TextBoxSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
57 Text="{x:Bind ViewModel.InitialAutoProxyTimeout, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextChanged="InitialAutoProxyTimeoutTextBox_TextChanged"/>
58 <Button x:Uid="Settings_InitialAutoProxyTimeoutResetButton" Style="{StaticResource ButtonSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
59 Command="{x:Bind ViewModel.InitialAutoProxyTimeout_ResetCommand}" IsEnabled="{x:Bind ViewModel.InitialAutoProxyTimeout_ResetEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
src/windows/wslsettings/Views/Settings/NetworkingPage.xaml.cs
+8
@@ -26,6 +26,14 @@ public sealed partial class NetworkingPage : Page
26 FrameworkElementAutomationPeer.FromElement(Settings_ErrorTryAgainLater).RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
27 }
28 });
29 +
30 + this.Loaded += OnPageLoaded;
31 + }
32 +
33 + private void OnPageLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
34 + {
35 + RuntimeHelper.SetupExpanderFocusManagementByName(this, "IgnoredPortsExpander", "IgnoredPortsTextBox");
36 + RuntimeHelper.SetupExpanderFocusManagementByName(this, "InitialAutoProxyTimeoutExpander", "InitialAutoProxyTimeoutTextBox");
37 }
38
39 override protected void OnNavigatedFrom(NavigationEventArgs e)
src/windows/wslsettings/Views/Settings/OptionalFeaturesPage.xaml
+2 -2
@@ -38,12 +38,12 @@
38 <ctControls:SettingsCard x:Uid="Settings_SparseVHD">
39 <ToggleSwitch x:Uid="Settings_SparseVHDToggleSwitch" HorizontalAlignment="Right" MinWidth="0" IsOn="{x:Bind ViewModel.IsOnSparseVHD, Mode=TwoWay}"/>
40 </ctControls:SettingsCard>
41 - <ctControls:SettingsExpander x:Uid="Settings_VMIdleTimeout">
41 + <ctControls:SettingsExpander x:Name="VMIdleTimeoutExpander" x:Uid="Settings_VMIdleTimeout">
42 <TextBlock Style="{StaticResource TextBlockSettingStyle}" Text="{x:Bind ViewModel.VMIdleTimeout, Mode=OneWay, Converter={StaticResource MillisecondsStringConverter}}"/>
43 <ctControls:SettingsExpander.Items>
44 <ctControls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left" Margin="{StaticResource SettingsExpanderItemMargin}">
45 <StackPanel Orientation="Horizontal">
46 - <TextBox x:Uid="Settings_VMIdleTimeoutTextBox" Style="{StaticResource TextBoxFilePathStyle}" Margin="{StaticResource InputControlSpacingMargin}"
46 + <TextBox x:Name="VMIdleTimeoutTextBox" x:Uid="Settings_VMIdleTimeoutTextBox" Style="{StaticResource TextBoxFilePathStyle}" Margin="{StaticResource InputControlSpacingMargin}"
47 Text="{x:Bind ViewModel.VMIdleTimeout, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextChanged="VMIdleTimeoutTextBox_TextChanged"/>
48 <Button x:Uid="Settings_VMIdleTimeoutResetButton" Style="{StaticResource ButtonSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
49 Command="{x:Bind ViewModel.VMIdleTimeout_ResetCommand}" IsEnabled="{x:Bind ViewModel.VMIdleTimeout_ResetEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
src/windows/wslsettings/Views/Settings/OptionalFeaturesPage.xaml.cs
+8
@@ -26,6 +26,14 @@ public sealed partial class OptionalFeaturesPage : Page
26 FrameworkElementAutomationPeer.FromElement(Settings_ErrorTryAgainLater).RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
27 }
28 });
29 +
30 + this.Loaded += OnPageLoaded;
31 + }
32 +
33 + private void OnPageLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
34 + {
35 + RuntimeHelper.SetupExpanderFocusManagementByName(this, "SystemdSettingsExpander", "InitTextBox");
36 + RuntimeHelper.SetupExpanderFocusManagementByName(this, "VMIdleTimeoutExpander", "VMIdleTimeoutTextBox");
37 }
38
39 override protected void OnNavigatedFrom(NavigationEventArgs e)