Saturday, 24 February 2018

Xamarin Forms ReturnType Key



Introduction:-
Hello Everybody Today I am going to tell about Entry Key ReturnType and How to change ReturnType keys like Search, Done and etc.
So In this article, I am using Xamarin Forms “PORTABLE" and XAML. this Handles Keyboard return a key description.

We generally found different caption on return type key while we are using keyboard in the mobile App. So, here I mentioned the way to achieve the different behaviors of return type keys in Xamarin Forms.

To customize return type key in android and ios we have to set following properties.

In iOS: UITextField has a ReturnKeyType property that you can set to a preassigned list.
In Android: EntryEditText have an ImeOptions property this property help to changing the EditText Key for Keyboard button.


Implementation:-
We are creating a class CustomKeyEntry.cs in PCL Project and writing the following C# code.
CustomKeyEntry.cs 

This property is set in the Android project as well as in iOS project.
Let us start with Android. We are creating a Class in Android Project and rendering the entry. 
Then, we set all the properties when initializing the PCL Project. 
Please make sure of the dependency ([assembly: ExportRenderer(typeof(CustomKeyEntry), typeof(CustomKeyEntryRenderer))]) of Android(CustomEntryRndered) and PCL(CustomEntry)…

CustomKeyEntryRenderer.cs

Now, it's time to go with iOS project.And we  set the PCL(CustomEntry) property in IOS Project….
 We are creating a Class , so we are  right click on iOS Project and select Apple. Then, select "Class" and give this class a name as CustomEntryRendered.cs.
[assembly: ExportRenderer(typeof(CustomKeyEntry), typeof(CustomKeyEntryRenderer))]
Now, let us write some code for Entry and Set Property.

CustomKeyEntryRenderer.cs

Now, go to the PCL Project and write this code in MainPage.xaml.
As you can see in the above code, we have to set the view reference in xmlns:custom="clr-namespace:CurvedEntry" MainPage.xaml.
Write the following code for CustomEntry.

MainPage.xaml

TADDAAAA!!
Now, you will have your Custom Entry working!!

if you want to watch this video click Here

Features of CustomReturnType controls

Custom ReturnType Property=(ReturnType="Search")

No comments:

Post a Comment

Featured Post

Sliding Entry In Xamarin.Forms

  Today, I am going to show you how to create a Custom Slide entry in Xamarin.Forms with animation and also using gradient color. here is Y...