-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixed DatePicker's DateSelected event not firing on Windows - NET 10 Preview 6 #30748
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
Changes from all commits
dc003ca
2559fb3
afcd64c
ac7cfdc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,10 @@ | ||||||||||||||||||||||
| using Microsoft.Maui.Controls; | ||||||||||||||||||||||
| using System; | ||||||||||||||||||||||
| using System.Threading.Tasks; | ||||||||||||||||||||||
| using Microsoft.Maui.Controls; | ||||||||||||||||||||||
| using Microsoft.Maui.Handlers; | ||||||||||||||||||||||
| using Microsoft.Maui.Hosting; | ||||||||||||||||||||||
| using System; | ||||||||||||||||||||||
| using System.Threading.Tasks; | ||||||||||||||||||||||
| using Xunit; | ||||||||||||||||||||||
| using Microsoft.Maui.Platform; | ||||||||||||||||||||||
| using Xunit; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| namespace Microsoft.Maui.DeviceTests; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -98,4 +98,58 @@ string GetDisplayedText(DatePickerHandler handler) | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| return string.Empty; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| [Fact(DisplayName = "DateSelected Event Fires When Platform View Date Changes")] | ||||||||||||||||||||||
| public async Task DateSelectedEventFiresWhenPlatformViewDateChanges() | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| SetupBuilder(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| var originalDate = new DateTime(2023, 5, 15); | ||||||||||||||||||||||
| var newDate = new DateTime(2023, 8, 20); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| var datePicker = new DatePicker | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| Date = originalDate | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| bool eventFired = false; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| datePicker.DateSelected += (sender, e) => | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| eventFired = true; | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| await CreateHandlerAndAddToWindow<DatePickerHandler>(datePicker, async (handler) => | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| await InvokeOnMainThreadAsync(() => | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| #if ANDROID | ||||||||||||||||||||||
| if (handler.DatePickerDialog != null) | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| var previousDate = handler.VirtualView.Date; | ||||||||||||||||||||||
| handler.VirtualView.Date = newDate; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| #elif IOS | ||||||||||||||||||||||
| if (handler.DatePickerDialog != null) | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| handler.DatePickerDialog.SetDate(newDate.ToNSDate(), false); | ||||||||||||||||||||||
| typeof(DatePickerHandler).GetMethod("SetVirtualViewDate", | ||||||||||||||||||||||
| System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)? | ||||||||||||||||||||||
| .Invoke(handler, null); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
||||||||||||||||||||||
| } | |
| } |
Copilot
AI
Jul 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation detected. This line uses spaces while the surrounding code uses tabs. Please maintain consistent indentation throughout the file.
| handler.PlatformView.Date = newDate; | |
| handler.PlatformView.Date = newDate; |
Copilot
AI
Jul 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation detected. This line uses spaces while the surrounding code uses tabs. Please maintain consistent indentation throughout the file.
| if (handler.PlatformView != null) | |
| { | |
| handler.PlatformView.Date = newDate; | |
| } | |
| if (handler.PlatformView != null) | |
| { | |
| handler.PlatformView.Date = newDate; | |
| } |
Copilot
AI
Jul 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation detected. This line uses spaces while the surrounding code uses tabs. Please maintain consistent indentation throughout the file.
| } | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation detected. This line uses spaces while the surrounding code uses tabs. Please maintain consistent indentation throughout the file.