Awesome Open Source
Awesome Open Source

Xamarin.DateTimePopups NuGet Badge

Little library of popups for picking dates and times

header

Available Platforms

Platform Version
Android MonoAndroid90+
iOS Xamarin.iOS10
.NET Standard 2.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)
iosDate androidDate iosTime androidTime

Powered by


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
C Sharp (279,380
Xamarin (1,776
Time (1,450
Xamarin Forms (1,251
Date (984
Datepicker (615
Picker (586
Xamarin Android (470
Popup (465
Xamarin Ios (330
Related Projects