Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Nullable Date Values in DatePicker #26979

Closed
VidyalakshmiMani opened this issue Jan 7, 2025 · 2 comments
Closed

Add Support for Nullable Date Values in DatePicker #26979

VidyalakshmiMani opened this issue Jan 7, 2025 · 2 comments

Comments

@VidyalakshmiMani
Copy link

Description

The .NET MAUI DatePicker control currently does not support null values for its Date property, which limits its usability in scenarios where dates are optional. Many applications require fields that allow users to leave a date unset or clear a previously selected value, such as "Date of Birth" or "Event Date." This enhancement adds the ability for the DatePicker control to handle nullable DateTime values (DateTime?).

Public API Changes

  1. New Property: AllowNull
    • Type: bool
    • Default: false
    • Description: Determines whether the DatePicker control allows the Date property to be set to null. When set to true, users can clear the date value, and the Date property can reflect null.

Intended Use-Case

  1. Optional Date Fields:
    Forms often include optional fields such as "Date of Birth" or "Event Date," where the user should have the flexibility to leave the date unset or clear a previously selected value.

  2. Reset Scenarios:
    Applications with reset functionality can use the AllowNull feature to clear date fields without additional code or custom logic.

@mattleibow
Copy link
Member

Not sure we need a new property, we can maybe make the existing property nullable?

I guess that would be breaking because we would go from DateTime to Nullable<DateTime>...

Maybe we can add a new Value property that is nullable and even a DateOnly #1100

@mattleibow
Copy link
Member

Duplicate of #1100

@mattleibow mattleibow marked this as a duplicate of #1100 Jan 7, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Feb 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants