Home

Awesome

Xamarin.DateTimePopups NuGet Badge

Little library of popups for picking dates and times

header

Available Platforms

PlatformVersion
AndroidMonoAndroid90+
iOSXamarin.iOS10
.NET Standard2.0

Getting started

This library can be used in Xamarin.iOS, Xamarin.Android or Xamarin.Forms projects

Android

In the Android project's MainLauncher or any Activity that is launched, this library must be initialized in the OnCreate method:

protected override void OnCreate(Bundle savedInstanceState)
{
    //...
    base.OnCreate(savedInstanceState);
    Xamarin.DateTimePopups.Platform.Init(this, savedInstanceState); // add this line to your code, it may also be called: bundle
    //...
}

iOS (Optional)

You can set the function to get the current UIView

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
    Xamarin.DateTimePopups.Platform.Init(()=> Xamarin.Essentials.Platform.GetCurrentUIViewController()?.View);
    global::Xamarin.Forms.Forms.Init();
    LoadApplication(new App());

    return base.FinishedLaunching(app, options);
}

Shared

using System;
using Xamarin.Forms;
using Xamarin.DateTimePopups;

namespace Sample.Views
{
    public partial class HomePage : ContentPage
    {
        public HomePage()
            => InitializeComponent();

        async void DateButton_Clicked(System.Object sender, System.EventArgs e)
        {
            DateTime? date = await DateTimePopups.PickDateAsync();
            ResultLabel.Text = date.ToString();
        }

        async void TimeButton_Clicked(System.Object sender, System.EventArgs e)
        {
            TimeSpan? date = await DateTimePopups.PickTimeAsync();
            ResultLabel.Text = date.ToString();
        }
    }
}

Screenshots

iOS (Date)Android (Date)iOS (Time)Android (Time)
iosDateandroidDateiosTimeandroidTime

Powered by