4 August 2022

Entry Example in MAUI

In this example we are going to see Entry 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.EntryEXP1"

             Title="EntryEXP1">

    <VerticalStackLayout>

        <Label 

            Text="Name:"

            VerticalOptions="Center" 

            HorizontalOptions="Center" />

        <Entry x:Name="ExtryName" Placeholder="Name" PlaceholderColor="Green"

            Keyboard="Text"   ></Entry>

        <Label 

            Text="Password:"

            VerticalOptions="Center" 

            HorizontalOptions="Center" />

        <Entry x:Name="ExtryPWD" Placeholder="Password" PlaceholderColor="Green"

              IsPassword="True" ></Entry>

        <Label 

            Text="Cell:"

            VerticalOptions="Center" 

            HorizontalOptions="Center" />

        <Entry x:Name="ExtryCell" Placeholder="Cell No" PlaceholderColor="Green"

             Keyboard="Numeric" TextChanged="ExtryCell_TextChanged" Completed="ExtryCell_Completed" ></Entry>

       

    </VerticalStackLayout>

</ContentPage>

2) Go to .CS page and update as below.

namespace MauiApp1;

public partial class EntryEXP1 : ContentPage

{

public EntryEXP1()

{

InitializeComponent();

}

private void ExtryCell_TextChanged(object sender, TextChangedEventArgs e)

{

DisplayAlert("TextChanged", ExtryCell.Text, "OK");

}

private void ExtryCell_Completed(object sender, EventArgs e)

{

        DisplayAlert("Completed", ExtryCell.Text, "OK");

    }

}

Output:



Code in Github: https://github.com/adi501/MAUI

No comments:

Post a Comment