-
Add the following NuGet package: https://www.nuget.org/packages/FormsPinView/
OR
add FormsPinView.PCL, FormsPinView.iOS, and FormsPinView.Droid to your solution.
-
Initialize iOS and Android renderers:
// iOS: public override bool FinishedLaunching(UIApplication app, NSDictionary options) { ... global::Xamarin.Forms.Forms.Init(); PinItemViewRenderer.Init(); } // Android: protected override void OnCreate(Bundle bundle) { ... global::Xamarin.Forms.Forms.Init(this, bundle); PinItemViewRenderer.Init(); }
-
Add PinView to your page:
... xmlns:local="clr-namespace:FormsPinView.PCL;assembly=FormsPinView.PCL" ... <local:PinView Title="🔐 Enter your PIN" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" BindingContext="{Binding PinViewModel}" />
-
PinView
is MVVM-ready, so you may inherit fromPinViewModel
:public class YourPageViewModel { ... public PinViewModel PinViewModel { get; private set; } = new PinViewModel { TargetPinLength = 4, ValidatorFunc = (arg) => { //TODO Check entered pin return true; } }; ... }
BSD 2-Clause.