diff --git a/src/Compatibility/Core/src/Android/Renderers/DatePickerRenderer.cs b/src/Compatibility/Core/src/Android/Renderers/DatePickerRenderer.cs
index 2c6a6526ddd0..43eb5f0d63d3 100644
--- a/src/Compatibility/Core/src/Android/Renderers/DatePickerRenderer.cs
+++ b/src/Compatibility/Core/src/Android/Renderers/DatePickerRenderer.cs
@@ -136,7 +136,11 @@ void IPickerRenderer.OnClick()
DatePicker view = Element;
((IElementController)view).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
- ShowPickerDialog(view.Date.Year, view.Date.Month - 1, view.Date.Day);
+ var year = view.Date?.Year ?? DateTime.Today.Year;
+ var month = (view.Date?.Month ?? DateTime.Today.Month) - 1;
+ var day = view.Date?.Day ?? DateTime.Today.Day;
+
+ ShowPickerDialog(year, month, day);
}
void ShowPickerDialog(int year, int month, int day)
@@ -164,19 +168,19 @@ void OnCancelButtonClicked(object sender, EventArgs e)
Element.Unfocus();
}
- void SetDate(DateTime date)
+ void SetDate(DateTime? date)
{
if (String.IsNullOrWhiteSpace(Element.Format))
{
- EditText.Text = date.ToShortDateString();
+ EditText.Text = date?.ToShortDateString();
}
else if (Element.Format.Contains('/', StringComparison.Ordinal))
{
- EditText.Text = date.ToString(Element.Format, CultureInfo.InvariantCulture);
+ EditText.Text = date?.ToString(Element.Format, CultureInfo.InvariantCulture);
}
else
{
- EditText.Text = date.ToString(Element.Format);
+ EditText.Text = date?.ToString(Element.Format);
}
}
@@ -198,7 +202,16 @@ void UpdateMaximumDate()
{
if (_dialog != null)
{
- _dialog.DatePicker.MaxDate = (long)Element.MaximumDate.ToUniversalTime().Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds;
+ if (Element.MaximumDate is null)
+ {
+ _dialog.DatePicker.MaxDate = (long)DateTime.MaxValue.ToUniversalTime()
+ .Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds;
+
+ return;
+ }
+
+ _dialog.DatePicker.MaxDate = (long)Element.MaximumDate.Value
+ .ToUniversalTime().Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds;
}
}
@@ -207,7 +220,16 @@ void UpdateMinimumDate()
{
if (_dialog != null)
{
- _dialog.DatePicker.MinDate = (long)Element.MinimumDate.ToUniversalTime().Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds;
+ if (Element.MinimumDate is null)
+ {
+ _dialog.DatePicker.MinDate = (long)DateTime.MinValue.ToUniversalTime()
+ .Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds;
+
+ return;
+ }
+
+ _dialog.DatePicker.MinDate = (long)Element.MinimumDate.Value
+ .ToUniversalTime().Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds;
}
}
diff --git a/src/Compatibility/Core/src/Windows/DatePickerRenderer.cs b/src/Compatibility/Core/src/Windows/DatePickerRenderer.cs
index 77b7f04b7b0d..1164c66771d6 100644
--- a/src/Compatibility/Core/src/Windows/DatePickerRenderer.cs
+++ b/src/Compatibility/Core/src/Windows/DatePickerRenderer.cs
@@ -127,9 +127,9 @@ void OnControlDateChanged(object sender, DatePickerValueChangedEventArgs e)
if (Element == null)
return;
- if (Element.Date.CompareTo(e.NewDate.Date) != 0)
+ if (Element.Date == null || Element.Date?.CompareTo(e.NewDate.Date) != 0)
{
- var date = e.NewDate.Date.Clamp(Element.MinimumDate, Element.MaximumDate);
+ var date = e.NewDate.Date.Clamp(Element.MinimumDate ?? DateTime.MinValue, Element.MaximumDate ?? DateTime.MaxValue);
Element.Date = date;
// set the control date-time to clamped value, if it exceeded the limits at the time of installation.
@@ -148,10 +148,10 @@ bool CheckDateFormat()
}
[PortHandler]
- void UpdateDate(DateTime date)
+ void UpdateDate(DateTime? date)
{
if (Control != null)
- Control.Date = new DateTimeOffset(new DateTime(date.Ticks, DateTimeKind.Unspecified));
+ Control.Date = new DateTimeOffset(new DateTime(date?.Ticks ?? 0, DateTimeKind.Unspecified));
UpdateDay();
UpdateMonth();
@@ -288,18 +288,18 @@ void UpdateFont()
void UpdateMaximumDate()
{
if (Element != null && Control != null)
- Control.MaxYear = new DateTimeOffset(new DateTime(Element.MaximumDate.Ticks, DateTimeKind.Unspecified));
+ Control.MaxYear = new DateTimeOffset(new DateTime(Element.MaximumDate?.Ticks ?? DateTime.MaxValue.Ticks, DateTimeKind.Unspecified));
}
[PortHandler]
void UpdateMinimumDate()
{
- DateTime mindate = Element.MinimumDate;
+ DateTime mindate = Element.MinimumDate ?? DateTime.MinValue;
try
{
if (Element != null && Control != null)
- Control.MinYear = new DateTimeOffset(new DateTime(Element.MinimumDate.Ticks, DateTimeKind.Unspecified));
+ Control.MinYear = new DateTimeOffset(new DateTime(Element.MinimumDate?.Ticks ?? DateTime.MinValue.Ticks, DateTimeKind.Unspecified));
}
catch (ArgumentOutOfRangeException)
{
diff --git a/src/Compatibility/Core/src/iOS/Renderers/DatePickerRenderer.cs b/src/Compatibility/Core/src/iOS/Renderers/DatePickerRenderer.cs
index 4e8cf6d1bdfa..e97fc197f131 100644
--- a/src/Compatibility/Core/src/iOS/Renderers/DatePickerRenderer.cs
+++ b/src/Compatibility/Core/src/iOS/Renderers/DatePickerRenderer.cs
@@ -176,8 +176,8 @@ void OnStarted(object sender, EventArgs eventArgs)
[PortHandler]
void UpdateDateFromModel(bool animate)
{
- if (_picker.Date.ToDateTime().Date != Element.Date.Date)
- _picker.SetDate(Element.Date.ToNSDate(), animate);
+ if (_picker.Date.ToDateTime().Date != Element.Date?.Date)
+ _picker.SetDate(Element.Date?.ToNSDate(), animate);
// Can't use Element.Format because it won't display the correct format if the region and language are set differently
if (string.IsNullOrWhiteSpace(Element.Format) || Element.Format.Equals("d", StringComparison.OrdinalIgnoreCase))
@@ -200,11 +200,11 @@ void UpdateDateFromModel(bool animate)
}
else if (Element.Format.Contains('/', StringComparison.Ordinal))
{
- Control.Text = Element.Date.ToString(Element.Format, CultureInfo.InvariantCulture);
+ Control.Text = Element.Date?.ToString(Element.Format, CultureInfo.InvariantCulture);
}
else
{
- Control.Text = Element.Date.ToString(Element.Format);
+ Control.Text = Element.Date?.ToString(Element.Format);
}
}
@@ -237,13 +237,13 @@ void UpdateCharacterSpacing()
[PortHandler]
void UpdateMaximumDate()
{
- _picker.MaximumDate = Element.MaximumDate.ToNSDate();
+ _picker.MaximumDate = Element.MaximumDate?.ToNSDate();
}
[PortHandler]
void UpdateMinimumDate()
{
- _picker.MinimumDate = Element.MinimumDate.ToNSDate();
+ _picker.MinimumDate = Element.MinimumDate?.ToNSDate();
}
[PortHandler]
diff --git a/src/Controls/docs/Microsoft.Maui.Controls/DateChangedEventArgs.xml b/src/Controls/docs/Microsoft.Maui.Controls/DateChangedEventArgs.xml
deleted file mode 100644
index 43d07adf02c0..000000000000
--- a/src/Controls/docs/Microsoft.Maui.Controls/DateChangedEventArgs.xml
+++ /dev/null
@@ -1,101 +0,0 @@
-
-
-
-
-
-
- Microsoft.Maui.Controls.Core
- 0.0.0.0
- 1.0.0.0
- 1.1.0.0
- 1.2.0.0
- 1.3.0.0
- 1.4.0.0
- 1.5.0.0
- 2.0.0.0
-
-
- System.EventArgs
-
-
-
- Event arguments for event.
-
-
-
-
-
-
-
- Constructor
-
- 0.0.0.0
- 1.0.0.0
- 1.1.0.0
- 1.2.0.0
- 1.3.0.0
- 1.4.0.0
- 1.5.0.0
- 2.0.0.0
- Microsoft.Maui.Controls.Core
-
-
-
-
-
-
- The old date.
- The new date.
- Creates a new object that represents a change from to .
-
-
-
-
-
-
-
- Property
-
- 0.0.0.0
- 1.0.0.0
- 1.1.0.0
- 1.2.0.0
- 1.3.0.0
- 1.4.0.0
- 1.5.0.0
- 2.0.0.0
- Microsoft.Maui.Controls.Core
-
-
- System.DateTime
-
-
- The date that the user entered.
-
-
-
-
-
-
-
- Property
-
- 0.0.0.0
- 1.0.0.0
- 1.1.0.0
- 1.2.0.0
- 1.3.0.0
- 1.4.0.0
- 1.5.0.0
- 2.0.0.0
- Microsoft.Maui.Controls.Core
-
-
- System.DateTime
-
-
- The date that was on the element at the time that the user selected it.
-
-
-
-
diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/DatePickerPage.xaml b/src/Controls/samples/Controls.Sample/Pages/Controls/DatePickerPage.xaml
index d90848035ec2..cc78cae0c9af 100644
--- a/src/Controls/samples/Controls.Sample/Pages/Controls/DatePickerPage.xaml
+++ b/src/Controls/samples/Controls.Sample/Pages/Controls/DatePickerPage.xaml
@@ -89,6 +89,14 @@
Margin="6, 0"
Style="{StaticResource IsFocusedTextStyle}"/>
-
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/DatePickerPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/DatePickerPage.xaml.cs
index 3e3b30bcd08a..92c417eee9b5 100644
--- a/src/Controls/samples/Controls.Sample/Pages/Controls/DatePickerPage.xaml.cs
+++ b/src/Controls/samples/Controls.Sample/Pages/Controls/DatePickerPage.xaml.cs
@@ -14,12 +14,12 @@ public DatePickerPage()
UpdateDatePickerBackground();
}
- void OnUpdateBackgroundButtonClicked(object sender, System.EventArgs e)
+ void OnUpdateBackgroundButtonClicked(object sender, EventArgs e)
{
UpdateDatePickerBackground();
}
- void OnClearBackgroundButtonClicked(object sender, System.EventArgs e)
+ void OnClearBackgroundButtonClicked(object sender, EventArgs e)
{
BackgroundDatePicker.Background = null;
}
@@ -41,14 +41,24 @@ void UpdateDatePickerBackground()
};
}
- void OnFocusDatePickerFocused(object sender, Microsoft.Maui.Controls.FocusEventArgs e)
+ void OnFocusDatePickerFocused(object sender, FocusEventArgs e)
{
Debug.WriteLine("Focused");
}
- void OnFocusDatePickerUnfocused(object sender, Microsoft.Maui.Controls.FocusEventArgs e)
+ void OnFocusDatePickerUnfocused(object sender, FocusEventArgs e)
{
Debug.WriteLine("Unfocused");
}
- }
+
+ void SetDatePickerToNull(object sender, EventArgs e)
+ {
+ NullDatePicker.Date = null;
+ }
+
+ void SetDatePickerToToday(object sender, EventArgs e)
+ {
+ NullDatePicker.Date = DateTime.Now;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Controls/src/Core/DateChangedEventArgs.cs b/src/Controls/src/Core/DateChangedEventArgs.cs
index 07fd59a9a2f2..3223399b5855 100644
--- a/src/Controls/src/Core/DateChangedEventArgs.cs
+++ b/src/Controls/src/Core/DateChangedEventArgs.cs
@@ -1,22 +1,30 @@
-#nullable disable
using System;
-namespace Microsoft.Maui.Controls
+namespace Microsoft.Maui.Controls;
+
+///
+/// Event arguments for event.
+///
+public class DateChangedEventArgs : EventArgs
{
- ///
- public class DateChangedEventArgs : EventArgs
+ ///
+ /// Creates a new object that represents a change from to
+ ///
+ /// The old date value.
+ /// The new date value.
+ public DateChangedEventArgs(DateTime? oldDate, DateTime? newDate)
{
- ///
- public DateChangedEventArgs(DateTime oldDate, DateTime newDate)
- {
- OldDate = oldDate;
- NewDate = newDate;
- }
+ OldDate = oldDate;
+ NewDate = newDate;
+ }
- ///
- public DateTime NewDate { get; private set; }
+ ///
+ /// The date that the user entered.
+ ///
+ public DateTime? NewDate { get; private set; }
- ///
- public DateTime OldDate { get; private set; }
- }
+ ///
+ /// The date that was on the element at the time that the user selected it.
+ ///
+ public DateTime? OldDate { get; private set; }
}
\ No newline at end of file
diff --git a/src/Controls/src/Core/DatePicker/DatePicker.cs b/src/Controls/src/Core/DatePicker/DatePicker.cs
index 66a916e989c6..ad05ae0d139d 100644
--- a/src/Controls/src/Core/DatePicker/DatePicker.cs
+++ b/src/Controls/src/Core/DatePicker/DatePicker.cs
@@ -14,17 +14,17 @@ public partial class DatePicker : View, IFontElement, ITextElement, IElementConf
public static readonly BindableProperty FormatProperty = BindableProperty.Create(nameof(Format), typeof(string), typeof(DatePicker), "d");
/// Bindable property for .
- public static readonly BindableProperty DateProperty = BindableProperty.Create(nameof(Date), typeof(DateTime), typeof(DatePicker), default(DateTime), BindingMode.TwoWay,
+ public static readonly BindableProperty DateProperty = BindableProperty.Create(nameof(Date), typeof(DateTime?), typeof(DatePicker), null, BindingMode.TwoWay,
coerceValue: CoerceDate,
propertyChanged: DatePropertyChanged,
defaultValueCreator: (bindable) => DateTime.Today);
/// Bindable property for .
- public static readonly BindableProperty MinimumDateProperty = BindableProperty.Create(nameof(MinimumDate), typeof(DateTime), typeof(DatePicker), new DateTime(1900, 1, 1),
+ public static readonly BindableProperty MinimumDateProperty = BindableProperty.Create(nameof(MinimumDate), typeof(DateTime?), typeof(DatePicker), new DateTime(1900, 1, 1),
validateValue: ValidateMinimumDate, coerceValue: CoerceMinimumDate);
/// Bindable property for .
- public static readonly BindableProperty MaximumDateProperty = BindableProperty.Create(nameof(MaximumDate), typeof(DateTime), typeof(DatePicker), new DateTime(2100, 12, 31),
+ public static readonly BindableProperty MaximumDateProperty = BindableProperty.Create(nameof(MaximumDate), typeof(DateTime?), typeof(DatePicker), new DateTime(2100, 12, 31),
validateValue: ValidateMaximumDate, coerceValue: CoerceMaximumDate);
/// Bindable property for .
@@ -54,9 +54,9 @@ public DatePicker()
}
///
- public DateTime Date
+ public DateTime? Date
{
- get { return (DateTime)GetValue(DateProperty); }
+ get { return (DateTime?)GetValue(DateProperty); }
set { SetValue(DateProperty, value); }
}
@@ -74,16 +74,16 @@ TextTransform ITextElement.TextTransform
}
///
- public DateTime MaximumDate
+ public DateTime? MaximumDate
{
- get { return (DateTime)GetValue(MaximumDateProperty); }
+ get { return (DateTime?)GetValue(MaximumDateProperty); }
set { SetValue(MaximumDateProperty, value); }
}
///
- public DateTime MinimumDate
+ public DateTime? MinimumDate
{
- get { return (DateTime)GetValue(MinimumDateProperty); }
+ get { return (DateTime?)GetValue(MinimumDateProperty); }
set { SetValue(MinimumDateProperty, value); }
}
@@ -123,6 +123,10 @@ public double FontSize
set { SetValue(FontSizeProperty, value); }
}
+ ///
+ /// Gets or sets whether the font size is automatically scaled based on the operating system's accessibility settings.
+ /// This is a bindable property.
+ ///
public bool FontAutoScalingEnabled
{
get => (bool)GetValue(FontAutoScalingEnabledProperty);
@@ -163,33 +167,43 @@ public virtual string UpdateFormsText(string source, TextTransform textTransform
static object CoerceDate(BindableObject bindable, object value)
{
var picker = (DatePicker)bindable;
- DateTime dateValue = ((DateTime)value).Date;
+ DateTime? dateValue = ((DateTime?)value)?.Date;
if (dateValue > picker.MaximumDate)
+ {
dateValue = picker.MaximumDate;
+ }
if (dateValue < picker.MinimumDate)
+ {
dateValue = picker.MinimumDate;
+ }
return dateValue;
}
static object CoerceMaximumDate(BindableObject bindable, object value)
{
- DateTime dateValue = ((DateTime)value).Date;
+ DateTime? dateValue = ((DateTime?)value)?.Date;
var picker = (DatePicker)bindable;
+
if (picker.Date > dateValue)
+ {
picker.Date = dateValue;
+ }
return dateValue;
}
static object CoerceMinimumDate(BindableObject bindable, object value)
{
- DateTime dateValue = ((DateTime)value).Date;
+ DateTime? dateValue = ((DateTime?)value)?.Date;
var picker = (DatePicker)bindable;
+
if (picker.Date < dateValue)
+ {
picker.Date = dateValue;
+ }
return dateValue;
}
@@ -199,18 +213,36 @@ static void DatePropertyChanged(BindableObject bindable, object oldValue, object
var datePicker = (DatePicker)bindable;
EventHandler selected = datePicker.DateSelected;
- if (selected != null)
- selected(datePicker, new DateChangedEventArgs((DateTime)oldValue, (DateTime)newValue));
+ if (selected is not null)
+ {
+ selected(datePicker, new DateChangedEventArgs((DateTime?)oldValue, (DateTime?)newValue));
+ }
}
static bool ValidateMaximumDate(BindableObject bindable, object value)
{
- return ((DateTime)value).Date >= ((DatePicker)bindable).MinimumDate.Date;
+ var newDate = (DateTime?)value;
+ var minimumDate = ((DatePicker)bindable).MinimumDate?.Date;
+
+ if (newDate is null || minimumDate is null)
+ {
+ return true;
+ }
+
+ return newDate.Value.Date >= minimumDate;
}
static bool ValidateMinimumDate(BindableObject bindable, object value)
{
- return ((DateTime)value).Date <= ((DatePicker)bindable).MaximumDate.Date;
+ var newDate = (DateTime?)value;
+ var maximumDate = ((DatePicker)bindable).MaximumDate?.Date;
+
+ if (newDate is null || maximumDate is null)
+ {
+ return true;
+ }
+
+ return newDate.Value.Date <= maximumDate;
}
///
@@ -230,7 +262,7 @@ void ITextElement.OnCharacterSpacingPropertyChanged(double oldValue, double newV
Font ITextStyle.Font => this.ToFont();
- DateTime IDatePicker.Date
+ DateTime? IDatePicker.Date
{
get => Date;
set => SetValue(DateProperty, value, SetterSpecificity.FromHandler);
diff --git a/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
index 032b6469a32e..d766c163b4dd 100644
--- a/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
+++ b/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
@@ -9,6 +9,18 @@
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.Style.set -> void
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.StyleClass.get -> System.Collections.Generic.IList
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.StyleClass.set -> void
+*REMOVED*Microsoft.Maui.Controls.DatePicker.Date.get -> System.DateTime
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.DateChangedEventArgs(System.DateTime oldDate, System.DateTime newDate) -> void
+Microsoft.Maui.Controls.DateChangedEventArgs.DateChangedEventArgs(System.DateTime? oldDate, System.DateTime? newDate) -> void
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.NewDate.get -> System.DateTime
+Microsoft.Maui.Controls.DateChangedEventArgs.NewDate.get -> System.DateTime?
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.OldDate.get -> System.DateTime
+Microsoft.Maui.Controls.DateChangedEventArgs.OldDate.get -> System.DateTime?
+Microsoft.Maui.Controls.DatePicker.Date.get -> System.DateTime?
+*REMOVED*Microsoft.Maui.Controls.DatePicker.MaximumDate.get -> System.DateTime
+*REMOVED*Microsoft.Maui.Controls.DatePicker.MinimumDate.get -> System.DateTime
+Microsoft.Maui.Controls.DatePicker.MaximumDate.get -> System.DateTime?
+Microsoft.Maui.Controls.DatePicker.MinimumDate.get -> System.DateTime?
Microsoft.Maui.Controls.HybridWebView.InvokeJavaScriptAsync(string! methodName, object?[]? paramValues = null, System.Text.Json.Serialization.Metadata.JsonTypeInfo?[]? paramJsonTypeInfos = null) -> System.Threading.Tasks.Task!
Microsoft.Maui.Controls.HybridWebView.SetInvokeJavaScriptTarget(T! target) -> void
Microsoft.Maui.Controls.Internals.TextTransformUtilities
diff --git a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
index 33f6c2c5e12d..8772f2e2473e 100644
--- a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
+++ b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
@@ -1,6 +1,18 @@
#nullable enable
Microsoft.Maui.Controls.ShadowTypeConverter
Microsoft.Maui.Controls.ShadowTypeConverter.ShadowTypeConverter() -> void
+*REMOVED*Microsoft.Maui.Controls.DatePicker.Date.get -> System.DateTime
+*REMOVED*Microsoft.Maui.Controls.DatePicker.MaximumDate.get -> System.DateTime
+*REMOVED*Microsoft.Maui.Controls.DatePicker.MinimumDate.get -> System.DateTime
+Microsoft.Maui.Controls.DatePicker.MaximumDate.get -> System.DateTime?
+Microsoft.Maui.Controls.DatePicker.MinimumDate.get -> System.DateTime?
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.DateChangedEventArgs(System.DateTime oldDate, System.DateTime newDate) -> void
+Microsoft.Maui.Controls.DateChangedEventArgs.DateChangedEventArgs(System.DateTime? oldDate, System.DateTime? newDate) -> void
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.NewDate.get -> System.DateTime
+Microsoft.Maui.Controls.DateChangedEventArgs.NewDate.get -> System.DateTime?
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.OldDate.get -> System.DateTime
+Microsoft.Maui.Controls.DateChangedEventArgs.OldDate.get -> System.DateTime?
+Microsoft.Maui.Controls.DatePicker.Date.get -> System.DateTime?
Microsoft.Maui.Controls.StyleableElement.Style.get -> Microsoft.Maui.Controls.Style?
Microsoft.Maui.Controls.Internals.TextTransformUtilities
override Microsoft.Maui.Controls.ShadowTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type? sourceType) -> bool
diff --git a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
index 7435ba760baa..d45799548a91 100644
--- a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
+++ b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
@@ -1,6 +1,18 @@
#nullable enable
Microsoft.Maui.Controls.ShadowTypeConverter
Microsoft.Maui.Controls.ShadowTypeConverter.ShadowTypeConverter() -> void
+*REMOVED*Microsoft.Maui.Controls.DatePicker.Date.get -> System.DateTime
+*REMOVED*Microsoft.Maui.Controls.DatePicker.MaximumDate.get -> System.DateTime
+*REMOVED*Microsoft.Maui.Controls.DatePicker.MinimumDate.get -> System.DateTime
+Microsoft.Maui.Controls.DatePicker.MaximumDate.get -> System.DateTime?
+Microsoft.Maui.Controls.DatePicker.MinimumDate.get -> System.DateTime?
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.DateChangedEventArgs(System.DateTime oldDate, System.DateTime newDate) -> void
+Microsoft.Maui.Controls.DateChangedEventArgs.DateChangedEventArgs(System.DateTime? oldDate, System.DateTime? newDate) -> void
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.NewDate.get -> System.DateTime
+Microsoft.Maui.Controls.DateChangedEventArgs.NewDate.get -> System.DateTime?
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.OldDate.get -> System.DateTime
+Microsoft.Maui.Controls.DateChangedEventArgs.OldDate.get -> System.DateTime?
+Microsoft.Maui.Controls.DatePicker.Date.get -> System.DateTime?
Microsoft.Maui.Controls.StyleableElement.Style.get -> Microsoft.Maui.Controls.Style?
Microsoft.Maui.Controls.Internals.TextTransformUtilities
override Microsoft.Maui.Controls.ShadowTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type? sourceType) -> bool
diff --git a/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
index b8cc6cb0a38f..bca9f259259d 100644
--- a/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
+++ b/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
@@ -9,6 +9,18 @@
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.Style.set -> void
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.StyleClass.get -> System.Collections.Generic.IList
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.StyleClass.set -> void
+*REMOVED*Microsoft.Maui.Controls.DatePicker.Date.get -> System.DateTime
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.DateChangedEventArgs(System.DateTime oldDate, System.DateTime newDate) -> void
+Microsoft.Maui.Controls.DateChangedEventArgs.DateChangedEventArgs(System.DateTime? oldDate, System.DateTime? newDate) -> void
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.NewDate.get -> System.DateTime
+Microsoft.Maui.Controls.DateChangedEventArgs.NewDate.get -> System.DateTime?
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.OldDate.get -> System.DateTime
+Microsoft.Maui.Controls.DateChangedEventArgs.OldDate.get -> System.DateTime?
+Microsoft.Maui.Controls.DatePicker.Date.get -> System.DateTime?
+*REMOVED*Microsoft.Maui.Controls.DatePicker.MaximumDate.get -> System.DateTime
+*REMOVED*Microsoft.Maui.Controls.DatePicker.MinimumDate.get -> System.DateTime
+Microsoft.Maui.Controls.DatePicker.MaximumDate.get -> System.DateTime?
+Microsoft.Maui.Controls.DatePicker.MinimumDate.get -> System.DateTime?
Microsoft.Maui.Controls.HybridWebView.InvokeJavaScriptAsync(string! methodName, object?[]? paramValues = null, System.Text.Json.Serialization.Metadata.JsonTypeInfo?[]? paramJsonTypeInfos = null) -> System.Threading.Tasks.Task!
Microsoft.Maui.Controls.HybridWebView.SetInvokeJavaScriptTarget(T! target) -> void
Microsoft.Maui.Controls.Internals.TextTransformUtilities
diff --git a/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt
index 9ef42960f9a9..e984ccaeb512 100644
--- a/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt
+++ b/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt
@@ -9,6 +9,18 @@
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.Style.set -> void
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.StyleClass.get -> System.Collections.Generic.IList
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.StyleClass.set -> void
+*REMOVED*Microsoft.Maui.Controls.DatePicker.Date.get -> System.DateTime
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.DateChangedEventArgs(System.DateTime oldDate, System.DateTime newDate) -> void
+Microsoft.Maui.Controls.DateChangedEventArgs.DateChangedEventArgs(System.DateTime? oldDate, System.DateTime? newDate) -> void
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.NewDate.get -> System.DateTime
+Microsoft.Maui.Controls.DateChangedEventArgs.NewDate.get -> System.DateTime?
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.OldDate.get -> System.DateTime
+Microsoft.Maui.Controls.DateChangedEventArgs.OldDate.get -> System.DateTime?
+Microsoft.Maui.Controls.DatePicker.Date.get -> System.DateTime?
+*REMOVED*Microsoft.Maui.Controls.DatePicker.MaximumDate.get -> System.DateTime
+*REMOVED*Microsoft.Maui.Controls.DatePicker.MinimumDate.get -> System.DateTime
+Microsoft.Maui.Controls.DatePicker.MaximumDate.get -> System.DateTime?
+Microsoft.Maui.Controls.DatePicker.MinimumDate.get -> System.DateTime?
Microsoft.Maui.Controls.HybridWebView.InvokeJavaScriptAsync(string! methodName, object?[]? paramValues = null, System.Text.Json.Serialization.Metadata.JsonTypeInfo?[]? paramJsonTypeInfos = null) -> System.Threading.Tasks.Task!
Microsoft.Maui.Controls.HybridWebView.SetInvokeJavaScriptTarget(T! target) -> void
Microsoft.Maui.Controls.Internals.TextTransformUtilities
diff --git a/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt
index 2e79dcf232bd..c49bb4427f07 100644
--- a/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt
+++ b/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt
@@ -9,6 +9,18 @@
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.Style.set -> void
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.StyleClass.get -> System.Collections.Generic.IList
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.StyleClass.set -> void
+*REMOVED*Microsoft.Maui.Controls.DatePicker.Date.get -> System.DateTime
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.DateChangedEventArgs(System.DateTime oldDate, System.DateTime newDate) -> void
+Microsoft.Maui.Controls.DateChangedEventArgs.DateChangedEventArgs(System.DateTime? oldDate, System.DateTime? newDate) -> void
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.NewDate.get -> System.DateTime
+Microsoft.Maui.Controls.DateChangedEventArgs.NewDate.get -> System.DateTime?
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.OldDate.get -> System.DateTime
+Microsoft.Maui.Controls.DateChangedEventArgs.OldDate.get -> System.DateTime?
+Microsoft.Maui.Controls.DatePicker.Date.get -> System.DateTime?
+*REMOVED*Microsoft.Maui.Controls.DatePicker.MaximumDate.get -> System.DateTime
+*REMOVED*Microsoft.Maui.Controls.DatePicker.MinimumDate.get -> System.DateTime
+Microsoft.Maui.Controls.DatePicker.MaximumDate.get -> System.DateTime?
+Microsoft.Maui.Controls.DatePicker.MinimumDate.get -> System.DateTime?
Microsoft.Maui.Controls.HybridWebView.InvokeJavaScriptAsync(string! methodName, object?[]? paramValues = null, System.Text.Json.Serialization.Metadata.JsonTypeInfo?[]? paramJsonTypeInfos = null) -> System.Threading.Tasks.Task!
Microsoft.Maui.Controls.HybridWebView.SetInvokeJavaScriptTarget(T! target) -> void
Microsoft.Maui.Controls.Internals.TextTransformUtilities
diff --git a/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt
index f9c1ba845497..42a2397fb7ae 100644
--- a/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt
+++ b/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt
@@ -9,6 +9,18 @@
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.Style.set -> void
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.StyleClass.get -> System.Collections.Generic.IList
*REMOVED*~Microsoft.Maui.Controls.NavigableElement.StyleClass.set -> void
+*REMOVED*Microsoft.Maui.Controls.DatePicker.Date.get -> System.DateTime
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.DateChangedEventArgs(System.DateTime oldDate, System.DateTime newDate) -> void
+Microsoft.Maui.Controls.DateChangedEventArgs.DateChangedEventArgs(System.DateTime? oldDate, System.DateTime? newDate) -> void
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.NewDate.get -> System.DateTime
+Microsoft.Maui.Controls.DateChangedEventArgs.NewDate.get -> System.DateTime?
+*REMOVED*Microsoft.Maui.Controls.DateChangedEventArgs.OldDate.get -> System.DateTime
+Microsoft.Maui.Controls.DateChangedEventArgs.OldDate.get -> System.DateTime?
+Microsoft.Maui.Controls.DatePicker.Date.get -> System.DateTime?
+*REMOVED*Microsoft.Maui.Controls.DatePicker.MaximumDate.get -> System.DateTime
+*REMOVED*Microsoft.Maui.Controls.DatePicker.MinimumDate.get -> System.DateTime
+Microsoft.Maui.Controls.DatePicker.MaximumDate.get -> System.DateTime?
+Microsoft.Maui.Controls.DatePicker.MinimumDate.get -> System.DateTime?
Microsoft.Maui.Controls.HybridWebView.InvokeJavaScriptAsync(string! methodName, object?[]? paramValues = null, System.Text.Json.Serialization.Metadata.JsonTypeInfo?[]? paramJsonTypeInfos = null) -> System.Threading.Tasks.Task!
Microsoft.Maui.Controls.HybridWebView.SetInvokeJavaScriptTarget(T! target) -> void
Microsoft.Maui.Controls.Internals.TextTransformUtilities
diff --git a/src/Controls/tests/Core.UnitTests/DatePickerUnitTest.cs b/src/Controls/tests/Core.UnitTests/DatePickerUnitTest.cs
index 05ce4cd4012a..1b64c051c6b9 100644
--- a/src/Controls/tests/Core.UnitTests/DatePickerUnitTest.cs
+++ b/src/Controls/tests/Core.UnitTests/DatePickerUnitTest.cs
@@ -20,6 +20,16 @@ public void TestMinimumDate()
Assert.Equal(new DateTime(1950, 1, 1), picker.MinimumDate);
}
+ [Fact]
+ public void TestMinimumDateNull()
+ {
+ DatePicker picker = new DatePicker();
+
+ picker.MinimumDate = null;
+
+ Assert.Null(picker.MinimumDate);
+ }
+
[Fact]
public void TestMaximumDate()
{
@@ -33,6 +43,16 @@ public void TestMaximumDate()
Assert.Equal(new DateTime(2050, 1, 1), picker.MaximumDate);
}
+ [Fact]
+ public void TestMaximumDateNull()
+ {
+ DatePicker picker = new DatePicker();
+
+ picker.MaximumDate = null;
+
+ Assert.Null(picker.MaximumDate);
+ }
+
[Fact]
public void TestMaximumDateClamping()
{
@@ -133,10 +153,12 @@ public void TestDateSelected()
Assert.True(selected);
}
- public static object[] DateTimes = {
+ readonly static object[] DateTimes = {
new object[] { new DateTime (2006, 12, 20), new DateTime (2011, 11, 30) },
new object[] { new DateTime (1900, 1, 1), new DateTime (1999, 01, 15) }, // Minimum Date
- new object[] { new DateTime (2006, 12, 20), new DateTime (2100, 12, 31) } // Maximum Date
+ new object[] { new DateTime (2006, 12, 20), new DateTime (2100, 12, 31) }, // Maximum Date
+ new object[] { new DateTime (2006, 12, 20), null },
+ new object[] { null, new DateTime (2006, 12, 20) },
};
public static IEnumerable