Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/MAUI/Maui.Samples/Views/SearchPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
Grid.Column="0"
ios:SearchBar.SearchBarStyle="Minimal"
Placeholder="Enter search term"
SearchCommand="{Binding PerformSearchCommand}"
SearchButtonPressed="SampleSearchBar_SearchButtonPressed"
Text="{Binding SearchText}">
<SearchBar.Behaviors>
<toolkit:UserStoppedTypingBehavior MinimumLengthThreshold="0" ShouldDismissKeyboardAutomatically="False" />
<toolkit:EventToCommandBehavior EventName="SearchButtonPressed"
Command="{Binding PerformSearchCommand}" />
<toolkit:UserStoppedTypingBehavior StoppedTypingTimeThreshold="3000" ShouldDismissKeyboardAutomatically="True"
Command="{Binding PerformSearchCommand}" />
</SearchBar.Behaviors>
</SearchBar>
<CollectionView Grid.Row="1"
Expand Down
6 changes: 6 additions & 0 deletions src/MAUI/Maui.Samples/Views/SearchPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ private async void CloseButton_Clicked(object sender, EventArgs e)
{
await Navigation.PopAsync(false);
}

private void SampleSearchBar_SearchButtonPressed(object sender, EventArgs e)
{
// Dismiss the keyboard when the search button is pressed.
SampleSearchBar.Unfocus();
}
}
Loading