Sebarslan.Maui.NullableDateTimePicker 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Sebarslan.Maui.NullableDateTimePicker --version 1.0.0                
NuGet\Install-Package Sebarslan.Maui.NullableDateTimePicker -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sebarslan.Maui.NullableDateTimePicker" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sebarslan.Maui.NullableDateTimePicker --version 1.0.0                
#r "nuget: Sebarslan.Maui.NullableDateTimePicker, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Sebarslan.Maui.NullableDateTimePicker as a Cake Addin
#addin nuget:?package=Sebarslan.Maui.NullableDateTimePicker&version=1.0.0

// Install Sebarslan.Maui.NullableDateTimePicker as a Cake Tool
#tool nuget:?package=Sebarslan.Maui.NullableDateTimePicker&version=1.0.0                

Maui Nullable and Clearable DateTimePicker

The Nullable DateTimePicker is a custom calendar control for selecting a nullable date and time value in a .NET MAUI application. It provides a consistent and platform-independent user interface for selecting dates, and allows the user to clear the value if needed.

This control uses the <a href="https://github.com/CommunityToolkit/Maui" target="_blank">CommunityToolkit.Maui</a> Popup.

Usage

To use the Nullable DateTimePicker control in your .NET MAUI application, follow these steps:

1- Add the NullableDateTimePicker control to your XAML layout file:

xmlns:ndtp="clr-namespace:Maui.NullableDateTimePicker;assembly=Maui.NullableDateTimePicker" <pre> <code> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:ndtp="clr-namespace:Maui.NullableDateTimePicker;assembly=Maui.NullableDateTimePicker" x:Class="Maui.NullableDateTimePicker.Samples.MainPage"> </code> </pre>

2- Bind the DateTime? value property to a property in your view model: <pre> <code> <ndtp:NullableDateTimePicker NullableDateTime="{Binding MyDateTime}" Mode="Date" /> </code> </pre>

3- Add .UseMauiCommunityToolkit() to the MauiProgram.cs file in your project. <pre> <code> public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder .UseMauiApp<App>() .UseMauiCommunityToolkit() .... </code> </pre>

More examples, please see the samples project

Options

Option Description Default Value
NullableDateTime Gets or sets the nullable date and time value of the control. null
Mode Specifies the mode of the control. Valid values are Date, DateTime, and Time. Date
Format Specifies the display format for the date or time. for date: d, for datetime: g, for time: t
MinDate Minimum selectable date of the control. DateTime.MinValue
MaxDate Maximum selectable date of the control. DateTime.MaxValue
OkButtonText The text for the OK button. OK
CancelButtonText The text for the Cancel button. Cancel
ClearButtonText Gets or sets the text for the Clear button. Clear
ShowClearButton Clear button can be hidden/shown. If true, the button is displayed. true
ForeColor It is used for the color of texts that cannot be styled in the calendar. Black
BackgroundColor Background color of the calendar. White
HeaderForeColor Gets or sets the foreground color of the control's header. White
HeaderBackgroundColor Background color of the control's header. #2b0b98
ToolButtonsStyle Style of the control's tool buttons. null
DayStyle Style of the days in the calendar. null
SelectedDayStyle Style of the selected day in the calendar. null
DayNamesStyle Style of the day names in the calendar. null
OtherMonthDayStyle Style of the other month days in the calendar. null
WeekNumberStyle Style of the week numbers in the calendar. null
ShowWeekNumbers Determines whether to display week numbers in the calendar. false
ShowOtherMonthDays Determines whether to display other month days in the calendar. true
CloseOnOutsideClick This option sets the calendar to close when clicked outside the popup component. false

NullableDateTimeChanged Event

The NullableDateTimeChanged event is used to indicate when a NullableDateTime value has been changed. This event is commonly used in programming or software environments and is triggered when the NullableDateTime value is modified.

The event utilizes the DateTimeChangedEventArgs class as its argument. The DateTimeChangedEventArgs class contains additional information that is carried at the moment the event is triggered. It may include details about the date and time change, such as the old DateTime value and the new DateTime value.

Below is an example code snippet illustrating the usage of the "NullableDateTimeChanged" event and the "DateTimeChangedEventArgs" argument class: <pre> <code> NullableDateTimePicker dateTimePicker = new NullableDateTimePicker(); dateTimePicker.NullableDateTimeChanged += OnNullableDateTimeChanged;

private static void OnNullableDateTimeChanged(object sender, DateTimeChangedEventArgs e) { Console.WriteLine("DateTime changed!"); Console.WriteLine("Old DateTime: " + e.OldDateTime); Console.WriteLine("New DateTime: " + e.NewDateTime); } </code> </pre>

License

The Nullable DateTimePicker control is licensed under the MIT License. See <a href="LICENSE.txt">LICENSE file</a> for more information.

Contributing

Contributions are welcome!

Screenshot

on ios, android, windows

Maui.DateTimePicker

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.3.1 7,498 5/9/2024
2.3.0 1,642 4/7/2024
2.2.0 1,880 2/21/2024
2.1.0 1,437 1/10/2024
2.0.0 317 12/4/2023
1.2.0 350 11/16/2023
1.1.1 233 11/3/2023
1.1.0 153 11/1/2023
1.0.2 653 9/16/2023
1.0.1 365 7/21/2023
1.0.0 207 7/2/2023