From dec9364fdbb83b92bd208e28fb892abf81a55a68 Mon Sep 17 00:00:00 2001 From: Hamish Duff <99325835+duffh@users.noreply.github.com> Date: Wed, 24 Jul 2024 10:06:47 +0100 Subject: [PATCH] [.NET MAUI] Focus search bar automatically on search page (#1491) --- src/MAUI/Maui.Samples/Views/SearchPage.xaml.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/MAUI/Maui.Samples/Views/SearchPage.xaml.cs b/src/MAUI/Maui.Samples/Views/SearchPage.xaml.cs index 75a8170063..1542b43e70 100644 --- a/src/MAUI/Maui.Samples/Views/SearchPage.xaml.cs +++ b/src/MAUI/Maui.Samples/Views/SearchPage.xaml.cs @@ -13,7 +13,15 @@ public SearchPage() InitializeComponent(); _viewModel = new SearchViewModel(); BindingContext = _viewModel; - } + + // Focus search bar when page loads. + SampleSearchBar.Loaded += SampleSearchBar_Loaded; + } + + private void SampleSearchBar_Loaded(object sender, EventArgs e) + { + SampleSearchBar.Focus(); + } private void TapGestureRecognizer_SearchResultTapped(object sender, TappedEventArgs e) {