In this tutorial series, we'll learn how to create and run your first .NET Multi-platform App UI (.NET MAUI) app in Visual Studio ...

.Net Multi-Platform App UI - MAUI Project Setup .Net Multi-Platform App UI - MAUI Project Setup

A blog about android developement

In this tutorial series, we'll learn how to create and run your first .NET Multi-platform App UI (.NET MAUI) app in Visual Studio 2022 on Windows, or Visual Studio 2022 for Mac 17.4 Preview.

Project Setup:

  • To create .NET MAUI apps, we need the latest Visual Studio 2022 installed with .NET Multi-platform App UI development workload with its default optional installation options in our PC or mac machine.
  • Launch Visual Studio 2022, and in the start window click Create a new project to create a new project.
  • In the Create a new project window, select MAUI in the All project types drop-down, select the .NET MAUI App template, and click the Next button:
  • In the Configure your new project window, name your project, choose a suitable location for it, and click the Next button:
  • In the Additional information window, click the Create button:
  • Once the project is created, we can able to see the Android, iOS, Windows and other running options in the toolbar. Press the emulator or run button to build and run the app
  • Visual Studio will build the app, and deploy the app to the emulator or device.
  • The sample app screen will be look like the below in Android, iOS and Windows.

    Android Output:

    iOS Output:

    Windows Output:

Introduction Xamarin.Essentials Xamarin.Essentials provides developers with cross-platform APIs for their mobile applications. Andro...

Xamarin.Forms - Text To Speech Using Xamarin Essentials Xamarin.Forms - Text To Speech Using Xamarin Essentials

A blog about android developement

Introduction

Xamarin.Essentials

Xamarin.Essentials provides developers with cross-platform APIs for their mobile applications. Android, iOS, and UWP offer unique operating system and platform APIs that developers have access to all in C# leveraging Xamarin. Xamarin.Essentials provides a single cross-platform API that works with any Xamarin.Forms, Android, iOS, or UWP application that can be accessed from shared code no matter how the user interface is created.

Text-to-Speech

This enables an application to utilize the built-in text-to-speech engines to speak back text from the device and also to query available languages that the engine can support.


Coding Part

Steps

  1. 1: Creating new Xamarin.Forms Projects
  2. 2: Implementation of Text to Speech in Xamarin Forms

Step 1: Creating new Xamarin.Forms Projects

Create New Project by selecting "New Project" à "Xamarin Cross Platform App" and Clicking "OK". Note: Xamarin.Forms version should be greater than 5.0.

Then Select Android and iOS Platforms as shown below with Code Sharing Strategy as PCL or .Net Standard and Click OK.

Step 2: Implementation of Text to Speech in Xamarin Forms

In this step, we will see how to implement the functionality in Xamarin.Forms.


Platform Specific Changes:

  • If your project's Target Android version is set to Android 11 (R API 30) you must update your Android Manifest with queries that are used with the new package visibility requirements.
  • Open the AndroidManifest.xml file under the Properties folder and add the following inside of the manifest node:

Xamarin Forms App Changes:

  • Add a reference to Xamarin.Essentials in your class:
  • Text-to-Speech works by calling the SpeakAsync method with text and optional parameters, and returns after the utterance has finished.
  • This API provide more options on how the audio is spoken back with SpeechOptions that allows setting the volume, pitch, and locale.

Full Code

Result

Download Code:

You can download the code from GitHub. If you have any doubts, feel free to post a comment. If you liked this article, and it is useful to you, do like, share the article & star the repository on GitHub.

This is a short article to announce the new features included in the SCRCPY GUI app. As a fan of SCRCPY, we are working on the new...

Install APK and take screenshot using SCRCPY GUI Install APK and take screenshot using SCRCPY GUI

A blog about android developement

SCRCPY Preview

This is a short article to announce the new features included in the SCRCPY GUI app. As a fan of SCRCPY, we are working on the new features including in it's companion app SCRCPY GUI and further more features will be added based on the ADB shell commands.

SCRCPY GUI New Features

  • Install Apk from PC to Android Phone
  • One Click option to take screenshot from PC

I have publihsed this app in GitHub as open source and requesting your contributions. I will be update this repository for new features.


Introduction In this tutorial, we will learn how to create and use app shortcuts in the xamarin forms app using Xamar...

App Shortcuts in Xamarin Forms App Shortcuts in Xamarin Forms

A blog about android developement

App Shortcuts in Xamarin Forms

Introduction

In this tutorial, we will learn how to create and use app shortcuts in the xamarin forms app using Xamarin Essentials - AppActions class lets you create and respond to app shortcuts from the app icon. This will allow to navigate to the corresponding page from the app icon.


Coding Part

Steps

  1. Step 1: Creating new Xamarin.Forms Projects
  2. Step 2: Setting up the App Actions in Android and iOS
  3. Step 3: Implementation of App Shortcuts in Xamarin Forms

Step 1: Creating new Xamarin.Forms Projects

Create New Project by selecting "New Project" à "Xamarin Cross Platform App" and Clicking "OK".
Note: Xamarin.Forms version should be greater than 5.0.

Then Select Android and iOS Platforms as shown below with Code Sharing Strategy as PCL or .Net Standard and Click OK.

Step 2: Setting up the App Actions in Android and iOS

    In this step, we will see how to setup the code for Android and iOS.

    Android Setup
  • Add Intentfilter for App Action in your MainActivity.cs class. Refer to the below image.
  • Then add the following logic to handle actions:
  • iOS Setup
  • In the AppDelegate.cs add the following logic to handle actions:

Step 3: Implementation of App Shortcuts in Xamarin Forms

In this step, we will see how to implement the functionality in Xamarin.Forms.

Create App Actions in Xamarin.Forms
  • App Actions can be created at any time, but are often created when an application starts. Call the SetAsync method to create the list of actions for your app.
  • If App Actions are not supported on the specific version of the operating system a FeatureNotSupportedException will be thrown. The following properties can be set on an AppAction:
    1. Id: A unique identifier used to respond to the action tap.
    2. Title: The visible title to display.
    3. Subtitle: If supported a sub-title to display under the title.
    4. Icon: Must match icons in the corresponding resources directory on each platform.
  • When your application starts register for the OnAppAction event. When an app action is selected the event will be sent with information as to which action was selected.
  • Full Code

    App.xaml.cs AppDelegate.cs MainActivity.cs MainPage.xaml.cs

    Result

    Download Code:

    You can download the code from GitHub. If you have any doubts, feel free to post a comment. If you liked this article, and it is useful to you, do like, share the article & star the repository on GitHub.

    Introduction In this tutorial, we will learn how to play a video or audio file in Xamarin.Forms applicati...

    Video Player App in Xamarin.Forms Video Player App in Xamarin.Forms

    A blog about android developement

    Video Player App in Xamarin.Forms

    Introduction

    In this tutorial, we will learn how to play a video or audio file in Xamarin.Forms application. This feature is not available by default in Xamarin Forms. So, we need to add an additional plugin to achieve these features. "MediaManager Plugin" offers this functionality."MediaManager Plugin" offers this functionality.


    Media Manager

    • Designed to be simple and easy to use
    • Native playback of media files from remote http(s), embedded and local sources
    • Native media notifications and remote controls
    • Queue and playback management by default
    • Playback status (Playing, Buffering, Loading, Paused, Progress)
    • Events for media handling to hook into

    Coding Part

    Steps

    1. Step 1: Creating new Xamarin.Forms Projects
    2. Step 2: Setting up the Media Manager in Xamarin.Forms .Net Standard Project
    3. Step 3: Implementation of Xamarin Forms - Video Player App

    Step 1: Creating new Xamarin.Forms Projects

    Create New Project by selecting "New Project" à "Xamarin Cross Platform App" and Clicking "OK".
    Note: Xamarin.Forms version should be greater than 5.0.

    Then Select Android and iOS Platforms as shown below with Code Sharing Strategy as PCL or .Net Standard and Click OK.

    Step 2: Setting up the Media Manager in Xamarin.Forms .Net Standard Project

      In this step, we will see how to setup the plugin.

    • Open the Nuget Manager in the Visual Studio Solution by right click the solution and selecting “Manage Nuget Packages”.
    • Then select below mentioned 2 plugins and check all the projects in the solution, install the plugin.
      • Plugin.MediaManager
      • Plugin.MediaManager.Forms

    Step 3: Implementation of Xamarin Forms - Video Player App

    In this step, add a VideoView control to your project. For that, go to Solution Explorer >> double click on MainPage.Xaml. After opening this, you can add VideoView assembly and XAML code to your project.

    • Include the video view control in your xaml file and add the button to perform play/pause operations.
    • We are going to play the video from the url as like in the below snippet.
    • Then add click event to perform the play and pause operations. We need to use the below mentioned code part to peform the play/pause operations using Media Manager
    • The final code behind will look like below.
    • Make sure to call " CrossMediaManager.Init(this, savedInstanceState); " for Android or " CrossMediaManager.Init(this); " for iOS from your platform code before starting playback, otherwise the video View will not be prepared to display the video.

    Result

    Download Code:

    You can download the code from GitHub. If you have any doubts, feel free to post a comment. If you liked this article, and it is useful to you, do like, share the article & star the repository on GitHub.

    SCRCPY and its feature SCRCPY pronounced "SCReen CoPY". This application provides display and control of Android devices co...

    How to mirror and control the Android Phone from PC using SCRCPY and SCRCPY-GUI How to mirror and control the Android Phone from PC using SCRCPY and SCRCPY-GUI

    A blog about android developement

    SCRCPY and its feature

    SCRCPY pronounced "SCReen CoPY". This application provides display and control of Android devices connected via USB or over TCP/IP. It does not require any root access. It works on GNU/Linux, Windows and macOS. I am a biggest fan of this tool even multiple tools (Vysor) are available in the market.

    It focuses on:

    • lightness: native, displays only the device screen
    • performance: 30~120fps, depending on the device
    • quality: 1920×1080 or above
    • low latency: 35~70ms
    • low startup time: ~1 second to display the first image
    • non-intrusiveness: nothing is left installed on the Android device
    • user benefits: no account, no ads, no internet required
    • freedom: free and open source software

    To know more about SCRCPY visit here.

    SCRCPY GUI

    I am big fan for SCRCPY. Thus I have built a small WinForms Application names as SCRCPY GUI to ease the device selection and screen mirroring using the SCRCPY, install the apk from the PC. Please find my tool details and the steps to using the  tool.

    We need to configure the ADB and SCRCPY in tool as like in the tool screenshots. You can download the SCRCPY from https://github.com/Genymobile/scrcpy/releases

    I have publihsed this app in GitHub as open source and requesting your contributions. I will be update this repository for new features.



    Introduction A Quick Tour in app allows us to understand what’s an application about and how the app work...

    Quick Tour using Xamarin Community Toolkit Quick Tour using Xamarin Community Toolkit

    A blog about android developement

    Introduction

    A Quick Tour in app allows us to understand what’s an application about and how the app works before using it. In this post, we are going to learn how to create a Quick Tour for the Xamarin Forms Application using the Xamarin Community Toolkit. This post is a part of Xamarin Community Toolkit - Tutorial Series. Please visit the post if you are new to Xamarin Community Toolkit.


    The Xamarin Community Toolkit is a collection of reusable elements for mobile development with Xamarin.Forms, including animations, behaviors, converters, effects, and helpers. It simplifies and demonstrates common developer tasks when building iOS, Android, macOS, WPF and Universal Windows Platform (UWP) apps using Xamarin.Forms.


    Xamarin Community Toolkit Popup

    The Popup control allows developers to create and display popups within their applications. The Popup can be extended to return data to the invocation code. This Popup can be used just like a ContentView or ContentPage is used in the Xamarin Forms Application.


    Coding Part

    Steps

    1. Step 1: Creating new Xamarin.Forms Projects.
    2. Step 2: Setting up the Xamarin Community Toolkit in Xamarin.Forms .Net Standard Project.
    3. Step 3: Implementation of Interactive Quick Tour using Xamarin Community Toolikit.

    Step 1: Creating new Xamarin.Forms Projects

    Create New Project by selecting "New Project" à "Xamarin Cross Platform App" and Click "OK".
    Note: Xamarin.Forms version should be greater than 5.0.

    Then Select Android and iOS Platforms as shown below with Code Sharing Strategy as PCL or .Net Standard and Click OK.

    Step 2: Setting up the Xamarin Community Toolkit in Xamarin.Forms .Net Standard Project.

      In this step, we will see how to setup the plugin.

    • Open the Nuget Manager in the Visual Studio Solution by right click the solution and select “Manage Nuget Packages”.
    • Then select “Xamarin Community Toolkit” and check all the projects in the solution, install the plugin

    Step 3: Implementation of Interactive Quick Tour using Xamarin Community Toolikit

    In this step, we will see how to implement the Quick Tour for the Xamarin Forms App using Popup offered in Xamarin Community Toolkit. This control allows you to have customised popup according the application requirement.


    I have divided the quick tour implementation into 3 steps, explained one by one.


    • In the each step will have a common footer that shows a Skip button, an actual Step indicator, and a Next button. I have created a BasePage that will contain a ContentView with the common part contains the above mentioned views along with the ContentView. This view is useful to display the different views on the each steps.

    • In the code behind, we will add the Next and Skip functions. Also will initialize them with the navigation logic, so that every time the next is executed it will remove the previous page, and navigate to the next page.

    • Each step will inherit from the BaseQuickTourPage and will wrap the view in the ContentView control. All the steps in the Quick Tour will be followed like the first step.

    • In order to handle which step/page goes next, I created a QuickTourBuilder using the builder pattern, which will handle the logic to indicate which step is going to go next.

    • On the first page of the Quick Tour, implement the IQuickTourLauncher interface, and use the LaunchAsync method to navigate to it.

    • In the sample page code-behind, we need to create the quick tour by using the QuickTourBuilder and specifying the sequence of pages that will be part of it like below.

    Result

    Download Code:

    You can download the code from GitHub.. If you have any doubts, feel free to post a comment. If you liked this article, and it is useful to you, do like, share the article & star the repository on GitHub..


    Introduction In this post, we are going to learn about the state layout which is offered in the Xamarin C...

    Xamarin Community Toolkit - State Layout Xamarin Community Toolkit -  State Layout

    A blog about android developement

    Introduction

    In this post, we are going to learn about the state layout which is offered in the Xamarin Community Toolkit and how do we implement it in our application. This post is a part of Xamarin Community Toolkit - Tutorial Series. Please visit the post if you are new to Xamarin Community Toolkit.


    The Xamarin Community Toolkit is a collection of reusable elements for mobile development with Xamarin.Forms, including animations, behaviors, converters, effects, and helpers. It simplifies and demonstrates common developer tasks when building iOS, Android, macOS, WPF and Universal Windows Platform (UWP) apps using Xamarin.Forms.


    State Layout is used for displaying a specific view when your app or screen is in a specific state. For example, displaying the activity indicator when the app is loading and waiting for a response from the service call.

    Coding Part

    Steps

    1. Step 1: Creating new Xamarin.Forms Projects.
    2. Step 2: Setting up the Xamarin Community Toolkit in Xamarin.Forms .Net Standard Project.
    3. Step 3: Implementation of State Layout using Xamarin Community Toolikit.

    Step 1: Creating new Xamarin.Forms Projects

    Create New Project by selecting "New Project" à "Xamarin Cross Platform App" and Click "OK".
    Note: Xamarin.Forms version should be greater than 5.0.

    Then Select Android and iOS Platforms as shown below with Code Sharing Strategy as PCL or .Net Standard and Click OK.

    Step 2: Setting up the Xamarin Community Toolkit in Xamarin.Forms .Net Standard Project.

      In this step, we will see how to setup the plugin.

    • Open the Nuget Manager in the Visual Studio Solution by right click the solution and select “Manage Nuget Packages”.
    • Then select “Xamarin Community Toolkit” and check all the projects in the solution, install the plugin

    Step 3: Implementation of State Layout using Xamarin Community Toolikit.

    In this step, we will see how to implement the state layout offered in Xamarin Community Toolkit. This control allows you to have different views according to a specific state. The view will change automatically according to the current state.

    • Open your XAML design file and add the following namespace to utilise the views in the screen.
      xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
    • This control offers the "StateToBooleanConverter" which will return true if the specified state matches the bound state. To use it you have to pass the state you want to check as the ConverterParameter.
      <ContentPage.Resources>
      	<xct:StateToBooleanConverter x:Key="StateToBooleanConverter" />
      </ContentPage.Resources>
    • This converter is useful for displaying the activity indicator based on the state like below
      <ActivityIndicator Color="#1abc9c" 
          IsRunning="{Binding MainState, Converter={StaticResource StateToBooleanConverter}, ConverterParameter={x:Static xct:LayoutState.Loading}}" />
    • Also, state layout has "AnimateStateChanges" property which indicates if you want an animated transition when switching between states.
      <StackLayout xct:StateLayout.CurrentState="{Binding MainState}"
      	xct:StateLayout.AnimateStateChanges="False">
      </StackLayout>
    • In this post, we will display the activity indicator when the state property changes and find the full code for the same below.

      Full Code:

      <?xml version="1.0" encoding="utf-8" ?>
      <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                   xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                   xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
                   xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
                   x:Class="XamarinCommunityToolkit.StateLayoutSamplePage"
                   xmlns:pg="clr-namespace:XamarinCommunityToolkit"
                   ios:Page.UseSafeArea="true">
          <ContentPage.BindingContext>
              <pg:StateLayoutSamplePageModel/>
          </ContentPage.BindingContext>
          <ContentPage.Resources>
              <xct:StateToBooleanConverter x:Key="StateToBooleanConverter" />
          </ContentPage.Resources>
          <ContentPage.Content>
              <Grid xct:StateLayout.CurrentState="{Binding MainState}" xct:StateLayout.AnimateStateChanges="true">
                  <xct:StateLayout.StateViews>
                      <xct:StateView StateKey="Loading" BackgroundColor="White" VerticalOptions="FillAndExpand">
                          <StackLayout VerticalOptions="Center" HorizontalOptions="Center">
                              <ActivityIndicator Color="#1abc9c" 
                                                 IsRunning="{Binding MainState, Converter={StaticResource StateToBooleanConverter}, ConverterParameter={x:Static xct:LayoutState.Loading}}" />
                              <Label Text="Loading..." HorizontalOptions="Center" />
                          </StackLayout>
                      </xct:StateView>
                  </xct:StateLayout.StateViews>
                  <Button Command="{Binding FullscreenLoadingCommand}" 
                          VerticalOptions="Center"
                          HorizontalOptions="Center"
                          Text="Show Fullscreen Loader" 
                          Margin="0,0,0,16" />
              </Grid>
          </ContentPage.Content>
      </ContentPage>
    • The state can be changed from the view model like below.
      FullscreenLoadingCommand = CommandFactory.Create(async () =>
      {
      	MainState = LayoutState.Loading;
      	await Task.Delay(2000);
      	MainState = LayoutState.None;
      });
    The Xamarin Community Toolkit - State Layout offering multiple properties and allow us to have custom states and please visit the below link for more details. https://docs.microsoft.com/en-us/xamarin/community-toolkit/views/statelayout

    Download Code:

    You can download the code from GitHub.. If you have any doubts, feel free to post a comment. If you liked this article, and it is useful to you, do like, share the article & star the repository on GitHub..


    Introduction In this post, we are going learn the behaviors offered in the Xamarin Community Toolkit and ...

    Xamarin Community Toolkit - Behaviors Xamarin Community Toolkit -  Behaviors

    A blog about android developement

    Introduction

    In this post, we are going learn the behaviors offered in the Xamarin Community Toolkit and how do we use them. This post is a part of Xamarin Community Toolkit - Tutorial Series and visit the post for know about the Xamarin Community Toolkit. The Xamarin Community Toolkit is a collection of reusable elements for mobile development with Xamarin.Forms, including animations, behaviors, converters, effects, and helpers. It simplifies and demonstrates common developer tasks when building iOS, Android, macOS, WPF and Universal Windows Platform (UWP) apps using Xamarin.Forms. 

    Coding Part

    Steps

    1. Step 1: Creating new Xamarin.Forms Projects.
    2. Step 2: Setting up the Xamarin Community Toolkit in Xamarin.Forms .Net Standard Project.
    3. Step 3: Implementation of Behaviors using Xamarin Community Toolikit.

    Step 1: Creating new Xamarin.Forms Projects

    Create New Project by Selecting New Project à Select Xamarin Cross Platform App and Click OK.

    Note: Xamarin.Forms version should be greater than 5.0.

    Then Select Android and iOS Platforms as shown below with Code Sharing Strategy as PCL or .Net Standard and Click OK.

    Step 2: Setting up the Xamarin Community Toolkit in Xamarin.Forms .Net Standard Project:

      In this step, we will see how to setup the plugin.

    • Open the Nuget Manager in the Visual Studio Solution by right click the solution and select “Manage Nuget Packages”.
    • Then select “Xamarin Community Toolkit” and check all the projects in the solution, install the plugin

    Step 3: Implementation of Behaviors using Xamarin Community Toolikit.

    In this step, we will see how to implement and use the behaviors offered in Xamarin Community Toolkit. Here, we have explained the implementation of Important behaviors with the registration form.

    • Open your XAML design file and add the following namespace to utilise the views in the screen.
      xmlns:xct="http://xamarin.com/schemas/2020/toolkit"

    Registration Form:

    • Create a form like in the following screen, which contains entries to get username, email, phone number and age.
    • SetFocusOnEntryCompletedBehavior:

    • The behavior gives focus to a specified visual element when an entry is completed. For example, a page might have several entries in sequence, and it would be convenient to the user if completing an entry automatically switched focus to the next entry.

      Code Part:

      <Entry xct:SetFocusOnEntryCompletedBehavior.NextElement="{x:Reference ent_email}" 
      	x:Name="ent_name" 
      	Placeholder="Username"/>
      <Entry xct:SetFocusOnEntryCompletedBehavior.NextElement="{x:Reference ent_phone}"
      	x:Name="ent_email"
      	Placeholder="Email"/>
    • EmailValidationBehavior:

    • The behavior allows users to determine whether or not text input is a valid e-mail address. For example, an Entry control can be styled differently depending on whether a valid or an invalid e-mail address is provided. The validation is achieved through a regular expression that is used to verify whether or not the text input is a valid e-mail address. It offers 2 properties "InvalidStyle" and "ValidStyle" will be applied based on this behavior output.

      Code Part:

      <Entry xct:SetFocusOnEntryCompletedBehavior.NextElement="{x:Reference ent_phone}"
      	   x:Name="ent_email"
      	   Placeholder="Email">
      	<Entry.Behaviors>
      		<xct:EmailValidationBehavior
      			InvalidStyle="{StaticResource InvalidEntryStyle}"
      			ValidStyle="{StaticResource ValidEntryStyle}"
      			DecorationFlags="Trim"/>
      	</Entry.Behaviors>
      </Entry>
    • MaskedBehavior:

    • The behavior allows the user to define an input mask for data entry. Adding this behavior to an Entry control will force the user to input only values that matching a given mask. Examples of its usage include input of a credit card number or a phone number with country code.

      Code Part:

      <Entry x:Name="ent_phone"
      	   Placeholder="Mobile Number"
      	   xct:SetFocusOnEntryCompletedBehavior.NextElement="{x:Reference ent_age}">
      	<Entry.Behaviors>
      		<xct:MaskedBehavior 
      			Mask="+AA-AAAAA-AAAAA" 
      			UnMaskedCharacter="A"/>
      	</Entry.Behaviors>
      </Entry>
    • NumericValidationBehavior:

    • The behavior allows the user to determine if text input is a valid numeric value. For example, an Entry control can be styled differently depending on whether a valid or an invalid numeric input is provided

      Code Part:

      <Entry x:Name="ent_age"
      	   Placeholder="Age"
      	   MaxLength="2"
      	   Keyboard="Numeric"
      	   xct:SetFocusOnEntryCompletedBehavior.NextElement="{x:Reference btn_submit}">
      	<Entry.Behaviors>
      		<xct:NumericValidationBehavior 
      			MaximumValue="35"
      			InvalidStyle="{StaticResource InvalidEntryStyle}"/>
      	</Entry.Behaviors>
      </Entry>

      MaxLengthReachedBehavior:

    • The behavior allows the user to trigger an action when a user has reached the maximum length allowed on an Entry. It can either trigger a Command or an event depending on the user scenario.

      Code Part:

      <Entry x:Name="ent_age"
      	   Placeholder="Age"
      	   MaxLength="2"
      	   Keyboard="Numeric"
      	   xct:SetFocusOnEntryCompletedBehavior.NextElement="{x:Reference btn_submit}">
      	<Entry.Behaviors>
      		<xct:MaxLengthReachedBehavior 
      			MaxLengthReached="MaxLengthReachedBehavior_MaxLengthReached"
      			ShouldDismissKeyboardAutomatically="True"/>
      	</Entry.Behaviors>
      </Entry>
    • AnimationBehavior:

    • The behavior allows the user to add an animation when an event is raised. It offers various built-in animations such as fade, flip and scale. These are exposed through an instance of the AnimationBase class.

      Code Part:

      <Button Text="Submit"
      		x:Name="btn_submit">
      	<Button.Behaviors>
      		<xct:AnimationBehavior EventName="Clicked">
      			<xct:AnimationBehavior.AnimationType>
      				<xct:FadeAnimation
      		Easing="{x:Static Easing.SinInOut}"
      		Duration="1000"/>
      			</xct:AnimationBehavior.AnimationType>
      		</xct:AnimationBehavior>
      	</Button.Behaviors>
      </Button>

    Full Code:

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 x:Class="XamarinCommunityToolkit.BehavioursSample">
        <ContentPage.Resources>
            <ResourceDictionary>
                <Style TargetType="Entry" x:Key="InvalidEntryStyle">
                    <Setter Property="TextColor" Value="Red"/>
                </Style>
                <Style TargetType="Entry" x:Key="ValidEntryStyle">
                    <Setter Property="TextColor" Value="Green"/>
                </Style>
            </ResourceDictionary>
        </ContentPage.Resources>
        <ContentPage.Content>
            <StackLayout Padding="20"
                         VerticalOptions="Center">
    
                <Label Text="Register Here..!"
                       TextColor="Orange"
                       FontSize="Title"
                       HorizontalOptions="Center"
                       Margin="0,0,0,10"/>
    
                <Entry xct:SetFocusOnEntryCompletedBehavior.NextElement="{x:Reference ent_email}"
                       x:Name="ent_name"
                       Placeholder="Username"/>
                <Entry xct:SetFocusOnEntryCompletedBehavior.NextElement="{x:Reference ent_phone}"
                       x:Name="ent_email"
                       Placeholder="Email">
                    <Entry.Behaviors>
                        <xct:EmailValidationBehavior
                            InvalidStyle="{StaticResource InvalidEntryStyle}"
                            ValidStyle="{StaticResource ValidEntryStyle}"
                            DecorationFlags="Trim"/>
                    </Entry.Behaviors>
                </Entry>
                <Entry x:Name="ent_phone"
                       Placeholder="Mobile Number"
                       xct:SetFocusOnEntryCompletedBehavior.NextElement="{x:Reference ent_age}">
                    <Entry.Behaviors>
                        <xct:MaskedBehavior 
                            Mask="+AA-AAAAA-AAAAA" 
                            UnMaskedCharacter="A"/>
                    </Entry.Behaviors>
                </Entry>
                <Entry x:Name="ent_age"
                       Placeholder="Age"
                       MaxLength="2"
                       Keyboard="Numeric"
                       xct:SetFocusOnEntryCompletedBehavior.NextElement="{x:Reference btn_submit}">
                    <Entry.Behaviors>
                        <xct:NumericValidationBehavior 
                            MaximumValue="35"
                            InvalidStyle="{StaticResource InvalidEntryStyle}"/>
                        <xct:MaxLengthReachedBehavior 
                            MaxLengthReached="MaxLengthReachedBehavior_MaxLengthReached"
                            ShouldDismissKeyboardAutomatically="True"/>
                    </Entry.Behaviors>
                </Entry>
                <Button Text="Submit"
                        x:Name="btn_submit">
                    <Button.Behaviors>
                        <xct:AnimationBehavior EventName="Clicked">
                            <xct:AnimationBehavior.AnimationType>
                                <xct:FadeAnimation
                        Easing="{x:Static Easing.SinInOut}"
                        Duration="1000"
                    />
                            </xct:AnimationBehavior.AnimationType>
                        </xct:AnimationBehavior>
                    </Button.Behaviors>
                </Button>
            </StackLayout>
        </ContentPage.Content>
    </ContentPage>

    Demo:

    The XCT offering multiple behaviors and please visit the below link for more samples. https://github.com/xamarin/XamarinCommunityToolkit/tree/main/samples/XCT.Sample/Pages/Behaviors

    Download Code:

    You can download the code from GitHub. If you have doubt, feel free to post comment. If you like this article and is useful to you, do like, share the article & star the repository on GitHub.