In this example we are going to see SearchBar Example in MAUI.
1) Add new page and Update code as below.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp1.SearchBarEXP1"
Title="SearchBarEXP1">
<VerticalStackLayout>
<SearchBar x:Name="SearchBarName"
SearchButtonPressed="SearchBarName_SearchButtonPressed"></SearchBar>
</VerticalStackLayout>
</ContentPage>
2) Go to .CS page and update as below.
namespace MauiApp1;
public partial class SearchBarEXP1 : ContentPage
{
public SearchBarEXP1()
{
InitializeComponent();
}
private void SearchBarName_SearchButtonPressed(object sender, EventArgs e)
{
DisplayAlert("Search Alert", SearchBarName.Text, "OK");
}
}
Output:
Code in Github: https://github.com/adi501/MAUI
No comments:
Post a Comment