From a4103ab0e27be898f6219821b761e0be04fae3d9 Mon Sep 17 00:00:00 2001 From: Andrew KeepCoding Date: Thu, 6 Mar 2025 14:57:14 +0900 Subject: [PATCH] Set focus to the search box when the app is loaded --- CommunityToolkit.App.Shared/Pages/Shell.xaml.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CommunityToolkit.App.Shared/Pages/Shell.xaml.cs b/CommunityToolkit.App.Shared/Pages/Shell.xaml.cs index e69e2ac4..2da7650a 100644 --- a/CommunityToolkit.App.Shared/Pages/Shell.xaml.cs +++ b/CommunityToolkit.App.Shared/Pages/Shell.xaml.cs @@ -27,6 +27,8 @@ public Shell() BackdropMaterial.SetApplyToRootOrPageBackground(this, true); #endif Current = this; + + Loaded += Shell_Loaded; } /// @@ -36,9 +38,13 @@ protected override void OnNavigatedTo(NavigationEventArgs e) { samplePages = e.Parameter as IEnumerable; SetupNavigationMenu(); - base.OnNavigatedTo(e); + base.OnNavigatedTo(e); } + private void Shell_Loaded(object sender, RoutedEventArgs e) + { + searchBox.Focus(FocusState.Programmatic); + } private void SetupNavigationMenu() {