Skip to content
Xamarin.Forms Plugin to customize the Xamarin.Forms.Entry Keyboard Return Button
Branch: master
Clone or download
Latest commit d5d86b4 Apr 23, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.mfractor Added [EditorBrowsable(EditorBrowsableState.Never)] to EffectsConstan… Mar 31, 2018
EntryCustomReturn.Forms.Plugin.Abstractions Updated NuGet Packages Apr 23, 2019
EntryCustomReturn.Forms.Plugin.Android Changed Default Value of CanExecute to true Dec 11, 2018
EntryCustomReturn.Forms.Plugin.UWP Changed Default Value of CanExecute to true Dec 11, 2018
EntryCustomReturn.Forms.Plugin.iOSUnified Updated NuGet Packages Apr 23, 2019
EntryCustomReturnSampleApp.Droid Update NuGet Packages Apr 22, 2019
EntryCustomReturnSampleApp.Shared/Constants Merge branch 'master' into release-3.3.0 Jan 6, 2018
EntryCustomReturnSampleApp.UITests Updated NuGet Packages Apr 23, 2019
EntryCustomReturnSampleApp.UWP Update NuGet Packages Apr 22, 2019
EntryCustomReturnSampleApp.iOS Update NuGet Packages Apr 22, 2019
EntryCustomReturnSampleApp Updated NuGet Packages for Samples & UITests Dec 11, 2018
EntryCustomReturnXamlSampleApp.Droid Updated NuGet Packages Apr 23, 2019
EntryCustomReturnXamlSampleApp.UITests Updated NuGet Packages Apr 23, 2019
EntryCustomReturnXamlSampleApp.iOS Update NuGet Packages Apr 22, 2019
EntryCustomReturnXamlSampleApp Update NuGet Packages Apr 22, 2019
MvvmSamples.Common.Forms Update NuGet Packages Apr 22, 2019
MvvmSamples.Shared Added CommandParameters Jan 6, 2018
MvvmSamples.UITests.Shared Updated NuGet Packages for Samples & UITests Dec 11, 2018
SimpleSample.Common Update NuGet Packages Apr 22, 2019
SimpleSample.Droid Update NuGet Packages Apr 22, 2019
SimpleSample.UITests Updated NuGet Packages Apr 23, 2019
SimpleSample.UWP Updated for Command Parameters Jan 5, 2018
SimpleSample.iOS Update NuGet Packages Apr 22, 2019
SimpleSample Updated NuGet Packages for Samples & UITests Dec 11, 2018
SimpleSamples.Shared Added CanExecuteSwitch to CustomRendererPage Feb 12, 2018
SimpleSamples.UITests.Shared Updated NuGet Packages for Samples & UITests Dec 11, 2018
SimpleXamlSample.Droid Update NuGet Packages Apr 22, 2019
SimpleXamlSample.UITests Updated NuGet Packages Apr 23, 2019
SimpleXamlSample.iOS Update NuGet Packages Apr 22, 2019
SimpleXamlSample Update NuGet Packages Apr 22, 2019
Tests.Shared Updated NuGet Packages Apr 23, 2019
.gitattributes 🍭 Added .gitattributes Jan 22, 2017
.gitignore Updated gitignore Jan 22, 2017
EntryCustomReturn.sln Replaced NuGet Package with NetStandard Jan 15, 2018
Plugin.nuspec Added DebugSymbols, Updated NuGet Image Url Dec 11, 2018
README.md Update README.md Jan 3, 2019
license Create license Jan 22, 2017

README.md

Custom Xamarin.Forms.Entry Keyboard Return Button

ReturnType Android iOS UWP
Default
Done
Go
Next
Search
Send

Platform Support

Platform Supported Version
Xamarin.iOS Yes iOS 8+
Xamarin.iOS Unified Yes iOS 8+
Xamarin.Android Yes API 15+
Windows 10 UWP Yes 10+
Windows Phone Silverlight No
Windows Phone RT No
Windows Store RT No
Xamarin.Mac No

This plugin can be consumed as a CustomRenderer Control or as an Effect.

Setup

iOS

In the FinishedLaunching method of AppDelegate.cs, add CustomReturnEntryRenderer.Init();:

public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        ...

        global::Xamarin.Forms.Forms.Init();
        
        EntryCustomReturn.Forms.Plugin.iOS.CustomReturnEntryRenderer.Init();

        ...
    }
}

Note: You must call EntryCustomReturn.Forms.Plugin.iOS.CustomReturnEntryRenderer.Init(); after you call global::Xamarin.Forms.Forms.Init();

Android

In the Oncreated method of MainActivity.cs, add CustomReturnEntryRenderer.Init();:

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
    protected override void OnCreate(Bundle bundle)
    {
        ...

        global::Xamarin.Forms.Forms.Init(this, bundle);

        EntryCustomReturn.Forms.Plugin.Android.CustomReturnEntryRenderer.Init();

        ...
    }
}

Note: You must call EntryCustomReturn.Forms.Plugin.Android.CustomReturnEntryRenderer.Init(); after you call global::Xamarin.Forms.Forms.Init(this, bundle);

UWP

In the OnLaunched method of App.xaml.cs, add CustomReturnEntryRenderer.Init();:

public partial class App : Application
{
    protected override void OnLaunched(LaunchActivatedEventArgs e)
    {
        ...

        global::Xamarin.Forms.Forms.Init(e);

        EntryCustomReturn.Forms.Plugin.UWP.CustomReturnEntryRenderer.Init();

        ...
    }
}

Note: You must call EntryCustomReturn.Forms.Plugin.UWP.CustomReturnEntryRenderer.Init(); after you call global::Xamarin.Forms.Forms.Init(e);

Usage in Xamarin.Forms Project as a Custom Control

This plugin can be consumed as a CustomRenderer Control or as an Effect.

1. Set the ReturnType Property

The ReturnType property is an enum containing 6 different types: Default, Go, Next, Done, Send, Search.

Coded UI

var goReturnTypeCustomEntry = new CustomReturnEntry
{
    ReturnType = EntryCustomReturn.Forms.Plugin.Abstractions.ReturnType.Go
};

XAML UI

<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="SimpleXamlSample.CustomRendererPage"
    xmlns:entryCustomReturn="clr-namespace:EntryCustomReturn.Forms.Plugin.Abstractions;assembly=EntryCustomReturn.Forms.Plugin.Abstractions">

    <ContentPage.Content>

        <entryCustomReturn:CustomReturnEntry
            x:Name = "MyCustomReturnEntry"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            ReturnType="Go"/>

    </ContentPage.Content>
</ContentPage>

Bindable Property

ReturnType can also be used as a Bindable Property to bind to a ViewModel

Coded UI

var viewModel = new MyViewModel();
BindingContext = viewModel;

var customReturnEntry = new CustomReturnEntry();
customReturnEntry.SetBinding(CustomReturnEntry.ReturnTypeProperty, nameof(MyViewModel.EntryReturnType));

XAML UI

<entryCustomReturn:CustomReturnEntry
    x:Name = "MyCustomReturnEntry"
    HorizontalOptions="Center"
    VerticalOptions="Center"
    ReturnType="{Binding EntryReturnType}"/>

2. Set the ReturnCommand Command

ReturnCommand will fire when the user finalizes the text in an entry with the return key.

Coded UI

goReturnTypeCustomEntry.ReturnCommand = new Command(() => Navigation.PushAsync(new ContentPage()));

XAML UI

Use the Coded UI example above to initialize a Command in the XAML Code Behind

Bindable Property

ReturnCommand can also be used as a Bindable Property to bind to a ViewModel

Coded UI

var viewModel = new MyViewModel();
BindingContext = viewModel;

var customReturnEntry = new CustomReturnEntry();
customReturnEntry.SetBinding(CustomReturnEntry.ReturnCommandProperty nameof(MyViewModel.EntryReturnCommand));

XAML UI

<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:SimpleXamlSample"
    x:Class="SimpleXamlSample.CustomRendererPage"
    xmlns:entryCustomReturn="clr-namespace:EntryCustomReturn.Forms.Plugin.Abstractions;assembly=EntryCustomReturn.Forms.Plugin.Abstractions"
    BindingContext="{Binding Source={local:MyViewModel}}">

    <ContentPage.Content>

        <entryCustomReturn:CustomReturnEntry
            x:Name = "MyCustomReturnEntry"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            ReturnCommand="{Binding EntryReturnCommand}"/>

    </ContentPage.Content>
</ContentPage>

3. Set the ReturnCommandParameter Property

The ReturnCommandParameter property is an object that can be passed to the ReturnCommand property.

Coded UI

goReturnTypeCustomEntry.ReturnCommand = new Command<string>(async title => await DisplayAlert(title, "", "Ok"));
goReturnTypeCustomEntry.ReturnCommandParameter = "Return Button Tapped";

XAML UI

<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="SimpleXamlSample.CustomRendererPage"
    xmlns:entryCustomReturn="clr-namespace:EntryCustomReturn.Forms.Plugin.Abstractions;assembly=EntryCustomReturn.Forms.Plugin.Abstractions">

    <ContentPage.Content>

        <entryCustomReturn:CustomReturnEntry
            x:Name = "MyCustomReturnEntry"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            ReturnCommandParameter="Return Button Tapped"/>

    </ContentPage.Content>
</ContentPage>

Bindable Property

ReturnCommandParameter can also be used as a Bindable Property to bind to a ViewModel

Coded UI

var viewModel = new MyViewModel();
BindingContext = viewModel;

var customReturnEntry = new CustomReturnEntry();
customReturnEntry.SetBinding(CustomReturnEntry.ReturnCommandParameterProperty, nameof(MyViewModel.EntryReturnCommandParameter));

XAML UI

<entryCustomReturn:CustomReturnEntry
    x:Name = "MyCustomReturnEntry"
    HorizontalOptions="Center"
    VerticalOptions="Center"
    ReturnCommandParameter="{Binding EntryReturnCommandParameter}"/>

Usage in Xamarin.Forms Project as an Effect

This plugin can be consumed as a CustomRenderer Control or as an Effect.

1. Set the ReturnType Property

The ReturnType property is an enum containing 6 different types: Default, Go, Next, Done, Send, Search.

Coded UI

var goReturnTypeEntry = new Entry()
CustomReturnEffect.SetReturnType(goReturnTypeEntry, EntryCustomReturn.Forms.Plugin.Abstractions.ReturnType.Go);

XAML UI

<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="SimpleXamlSample.CustomRendererPage"
    xmlns:entryCustomReturn="clr-namespace:EntryCustomReturn.Forms.Plugin.Abstractions;assembly=EntryCustomReturn.Forms.Plugin.Abstractions">

    <ContentPage.Content>

        <Entry
            x:Name = "GoReturnTypeEntry"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            entryCustomReturn:CustomReturnEffect.ReturnType="{x:Static entryCustomReturn:ReturnType.Default}"/>


    </ContentPage.Content>
</ContentPage>

Bindable Property

ReturnType can also be used as a Bindable Property to bind to a ViewModel

Coded UI

var viewModel = new MyViewModel();
BindingContext = viewModel;

var customReturnEntry = new Entry();
customReturnEntry.SetBinding(CustomReturnEffect.ReturnTypeProperty, nameof(MyViewModel.EntryReturnType));

XAML UI

<Entry
    x:Name = "GoReturnTypeEntry"
    HorizontalOptions="Center"
    VerticalOptions="Center"
    entryCustomReturn:CustomReturnEffect.ReturnType="{Binding EntryReturnType}"/>

2. Set the ReturnCommand Command

ReturnCommand will fire when the user finalizes the text in an entry with the return key.

Coded UI

var goReturnTypeEntry = new Entry()
CustomReturnEffect.SetReturnCommand(goReturnTypeEntry, new Command(() => Navigation.PushAsync(new ContentPage()));

XAML UI

Use the Coded UI example above to initialize a Command in the XAML Code Behind

Bindable Property

ReturnCommand can also be used as a Bindable Property to bind to a ViewModel

Coded UI

var viewModel = new MyViewModel();
BindingContext = viewModel;

var customReturnEntry = new Entry();
customReturnEntry.SetBinding(CustomReturnEffect.ReturnCommandProperty, nameof(MyViewModel.EntryReturnCommand));

XAML UI

<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="SimpleXamlSample"
    x:Class="SimpleXamlSample.CustomRendererPage"
    xmlns:entryCustomReturn="clr-namespace:EntryCustomReturn.Forms.Plugin.Abstractions;assembly=EntryCustomReturn.Forms.Plugin.Abstractions"
    BindingContext="{Binding Source={local:MyViewModel}}">

    <ContentPage.Content>

        <entryCustomReturn:CustomReturnEntry
            x:Name = "MyCustomReturnEntry"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            entryCustomReturn:CustomReturnEffect.ReturnCommand="{Binding EntryReturnCommand}"/>

    </ContentPage.Content>
</ContentPage>

3. Set the ReturnCommandParameter Property

The ReturnCommandParameter property is an object that can be passed to the ReturnCommand property.

Coded UI

var goReturnTypeEntry = new Entry()
CustomReturnEffect.SetReturnCommand(goReturnTypeEntry, new Command<string>(async title => await DisplayAlert(title, "", "Ok")));
CustomReturnEffect.SetReturnCommandParameter(goReturnTypeEntry, "Return Button Tapped");

XAML UI

<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="SimpleXamlSample.CustomRendererPage"
    xmlns:entryCustomReturn="clr-namespace:EntryCustomReturn.Forms.Plugin.Abstractions;assembly=EntryCustomReturn.Forms.Plugin.Abstractions">

    <ContentPage.Content>

        <entryCustomReturn:CustomReturnEntry
            x:Name = "MyCustomReturnEntry"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            entryCustomReturn:CustomReturnEffect.ReturnCommandParameter="Return Button Tapped"/>

    </ContentPage.Content>
</ContentPage>

Bindable Property

ReturnCommandParameter can also be used as a Bindable Property to bind to a ViewModel

Coded UI

var viewModel = new MyViewModel();
BindingContext = viewModel;

var customReturnEntry = new Entry();
customReturnEntry.SetBinding(CustomReturnEffect.ReturnCommandParameterProperty, nameof(MyViewModel.EntryReturnCommandParameter));

XAML UI

<entryCustomReturn:CustomReturnEntry
    x:Name = "MyCustomReturnEntry"
    HorizontalOptions="Center"
    VerticalOptions="Center"
    entryCustomReturn:CustomReturnEffect.ReturnCommandParameter="{Binding EntryReturnCommandParameter}"/>
You can’t perform that action at this time.