Skip to content

[iOS/MacCatalyst] DatePicker and TimePicker Background is not cleared when set to null at runtime - #36934

Merged
kubaflo merged 5 commits into
dotnet:inflight/currentfrom
HarishwaranVijayakumar:fix/datepicker-timepicker-background-null-ios
Aug 6, 2026
Merged

kubaflo merged 5 commits into
dotnet:inflight/currentfrom
HarishwaranVijayakumar:fix/datepicker-timepicker-background-null-ios

Conversation

@HarishwaranVijayakumar

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details:

  • DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible.

Root Cause of the issue:

  • On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path.

Description of Change

Platform handler updates:

  • Added internal MapBackground methods to both DatePickerHandler and TimePickerHandler for iOS and MacCatalyst, which remove the background layer and reset the background color when the Background property is set to null.
  • Updated property mappers in DatePickerHandler.cs and TimePickerHandler.cs to include the new MapBackground mapping for iOS and MacCatalyst.

Test coverage:

  • Added a new test case page (Issue36933) that allows toggling the background of DatePicker and TimePicker between a color and null at runtime.
  • Added a UI test verifying that the background is cleared when set to null and can be set to a new color.

Code maintenance:

  • Added missing using Microsoft.Maui.Graphics; directives to relevant files for background color handling.

Issues Fixed

Fixes #36933

Tested the behavior in the following platforms

  • Windows
  • Android
  • iOS
  • Mac

Output

Before After
withoutfix.mov
withfix.mov

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 36934

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 36934"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Jul 30, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @@HarishwaranVijayakumar! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@vishnumenon2684

Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests , maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@HarishwaranVijayakumar HarishwaranVijayakumar changed the title [WIP] [iOS/MacCatalyst] DatePicker and TimePicker Background is not cleared when set to null at runtime [iOS/MacCatalyst] DatePicker and TimePicker Background is not cleared when set to null at runtime Jul 30, 2026
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Aug 1, 2026
@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) labels Aug 1, 2026
@MauiBot

This comment has been minimized.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Aug 1, 2026
@kubaflo

This comment has been minimized.

@sheiksyedm
sheiksyedm marked this pull request as ready for review August 3, 2026 07:31
Copilot AI review requested due to automatic review settings August 3, 2026 07:31
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@kubaflo kubaflo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some test failures are related - could you please check?

Copilot AI review requested due to automatic review settings August 6, 2026 08:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 18 changed files in this pull request and generated no new comments.

Suppressed comments (3)

src/Core/src/Handlers/TimePicker/TimePickerHandler.cs:23

  • MacCatalyst builds likely won't execute this new Background mapper because the preprocessor condition excludes MACCATALYST. That means the new MapBackground implementation in TimePickerHandler.MacCatalyst.cs won't be used and the issue can remain on MacCatalyst.
#if IOS || ANDROID || WINDOWS
			[nameof(ITimePicker.Background)] = MapBackground,
#endif

src/Core/src/Handlers/DatePicker/DatePickerHandler.cs:30

  • The Background mapper is only enabled for ANDROID/WINDOWS and IOS. On MacCatalyst this will fall back to ViewHandler.ViewMapper, so the new MapBackground implementation in DatePickerHandler.MacCatalyst.cs won’t run and the background may still not clear at runtime.
#if ANDROID || WINDOWS
			[nameof(IDatePicker.Background)] = MapBackground,
#elif IOS
			[nameof(IDatePicker.Background)] = MapBackground,
			[nameof(IDatePicker.FlowDirection)] = MapFlowDirection,
#endif

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue36933.cs:20

  • The test only waits for the DatePicker, but the screenshots also validate the TimePicker’s background. Waiting for the TimePicker element as well will reduce screenshot flakiness/race conditions on slower devices.
		App.WaitForElement("TestDatePicker");

@HarishwaranVijayakumar

Copy link
Copy Markdown
Contributor Author

Looks like some test failures are related - could you please check?

I checked the CI failures, and they are not related.

@kubaflo
kubaflo changed the base branch from main to inflight/current August 6, 2026 15:30
@kubaflo
kubaflo merged commit 760fc63 into dotnet:inflight/current Aug 6, 2026
27 of 36 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR10 milestone Aug 6, 2026
kubaflo pushed a commit that referenced this pull request Aug 7, 2026
… when set to null at runtime (#36934)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details:

- DatePicker and TimePicker Background set to null at runtime does not
clear the background on iOS and MacCatalyst. The previously set
background color/brush remains visible.

### Root Cause of the issue:

- On iOS, ViewExtensions.UpdateBackground() has a type guard (line
84-89) that only clears BackgroundColor for LayoutView or ContentView
when paint is null — for all other UIView subclasses (including
UITextField/UIDatePicker used by DatePicker/TimePicker), it
early-returns without clearing. DatePicker and TimePicker didn't have
their own MapBackground registered for iOS/MacCatalyst (only
Android/Windows had it), so they fell through to this broken path.

### Description of Change

**Platform handler updates:**

* Added internal `MapBackground` methods to both `DatePickerHandler` and
`TimePickerHandler` for iOS and MacCatalyst, which remove the background
layer and reset the background color when the `Background` property is
set to `null`.
* Updated property mappers in `DatePickerHandler.cs` and
`TimePickerHandler.cs` to include the new `MapBackground` mapping for
iOS and MacCatalyst.

**Test coverage:**

* Added a new test case page (`Issue36933`) that allows toggling the
background of `DatePicker` and `TimePicker` between a color and `null`
at runtime.
* Added a UI test verifying that the background is cleared when set to
`null` and can be set to a new color.

**Code maintenance:**

* Added missing `using Microsoft.Maui.Graphics;` directives to relevant
files for background color handling.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36933

### Tested the behavior in the following platforms
 
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

### Output
 
| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2">
| <video
src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4">
|










<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Aug 12, 2026
… when set to null at runtime (#36934)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details:

- DatePicker and TimePicker Background set to null at runtime does not
clear the background on iOS and MacCatalyst. The previously set
background color/brush remains visible.

### Root Cause of the issue:

- On iOS, ViewExtensions.UpdateBackground() has a type guard (line
84-89) that only clears BackgroundColor for LayoutView or ContentView
when paint is null — for all other UIView subclasses (including
UITextField/UIDatePicker used by DatePicker/TimePicker), it
early-returns without clearing. DatePicker and TimePicker didn't have
their own MapBackground registered for iOS/MacCatalyst (only
Android/Windows had it), so they fell through to this broken path.

### Description of Change

**Platform handler updates:**

* Added internal `MapBackground` methods to both `DatePickerHandler` and
`TimePickerHandler` for iOS and MacCatalyst, which remove the background
layer and reset the background color when the `Background` property is
set to `null`.
* Updated property mappers in `DatePickerHandler.cs` and
`TimePickerHandler.cs` to include the new `MapBackground` mapping for
iOS and MacCatalyst.

**Test coverage:**

* Added a new test case page (`Issue36933`) that allows toggling the
background of `DatePicker` and `TimePicker` between a color and `null`
at runtime.
* Added a UI test verifying that the background is cleared when set to
`null` and can be set to a new color.

**Code maintenance:**

* Added missing `using Microsoft.Maui.Graphics;` directives to relevant
files for background color handling.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36933

### Tested the behavior in the following platforms
 
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

### Output
 
| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2">
| <video
src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4">
|










<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
@sheiksyedm sheiksyedm modified the milestones: .NET 10 SR10, .NET 10 SR11 Aug 26, 2026
kubaflo pushed a commit that referenced this pull request Aug 27, 2026
… when set to null at runtime (#36934)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details:

- DatePicker and TimePicker Background set to null at runtime does not
clear the background on iOS and MacCatalyst. The previously set
background color/brush remains visible.

### Root Cause of the issue:

- On iOS, ViewExtensions.UpdateBackground() has a type guard (line
84-89) that only clears BackgroundColor for LayoutView or ContentView
when paint is null — for all other UIView subclasses (including
UITextField/UIDatePicker used by DatePicker/TimePicker), it
early-returns without clearing. DatePicker and TimePicker didn't have
their own MapBackground registered for iOS/MacCatalyst (only
Android/Windows had it), so they fell through to this broken path.

### Description of Change

**Platform handler updates:**

* Added internal `MapBackground` methods to both `DatePickerHandler` and
`TimePickerHandler` for iOS and MacCatalyst, which remove the background
layer and reset the background color when the `Background` property is
set to `null`.
* Updated property mappers in `DatePickerHandler.cs` and
`TimePickerHandler.cs` to include the new `MapBackground` mapping for
iOS and MacCatalyst.

**Test coverage:**

* Added a new test case page (`Issue36933`) that allows toggling the
background of `DatePicker` and `TimePicker` between a color and `null`
at runtime.
* Added a UI test verifying that the background is cleared when set to
`null` and can be set to a new color.

**Code maintenance:**

* Added missing `using Microsoft.Maui.Graphics;` directives to relevant
files for background color handling.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36933

### Tested the behavior in the following platforms
 
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

### Output
 
| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2">
| <video
src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4">
|










<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Sep 2, 2026
… when set to null at runtime (#36934)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details:

- DatePicker and TimePicker Background set to null at runtime does not
clear the background on iOS and MacCatalyst. The previously set
background color/brush remains visible.

### Root Cause of the issue:

- On iOS, ViewExtensions.UpdateBackground() has a type guard (line
84-89) that only clears BackgroundColor for LayoutView or ContentView
when paint is null — for all other UIView subclasses (including
UITextField/UIDatePicker used by DatePicker/TimePicker), it
early-returns without clearing. DatePicker and TimePicker didn't have
their own MapBackground registered for iOS/MacCatalyst (only
Android/Windows had it), so they fell through to this broken path.

### Description of Change

**Platform handler updates:**

* Added internal `MapBackground` methods to both `DatePickerHandler` and
`TimePickerHandler` for iOS and MacCatalyst, which remove the background
layer and reset the background color when the `Background` property is
set to `null`.
* Updated property mappers in `DatePickerHandler.cs` and
`TimePickerHandler.cs` to include the new `MapBackground` mapping for
iOS and MacCatalyst.

**Test coverage:**

* Added a new test case page (`Issue36933`) that allows toggling the
background of `DatePicker` and `TimePicker` between a color and `null`
at runtime.
* Added a UI test verifying that the background is cleared when set to
`null` and can be set to a new color.

**Code maintenance:**

* Added missing `using Microsoft.Maui.Graphics;` directives to relevant
files for background color handling.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36933

### Tested the behavior in the following platforms
 
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

### Output
 
| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2">
| <video
src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4">
|










<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Sep 3, 2026
… when set to null at runtime (#36934)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details:

- DatePicker and TimePicker Background set to null at runtime does not
clear the background on iOS and MacCatalyst. The previously set
background color/brush remains visible.

### Root Cause of the issue:

- On iOS, ViewExtensions.UpdateBackground() has a type guard (line
84-89) that only clears BackgroundColor for LayoutView or ContentView
when paint is null — for all other UIView subclasses (including
UITextField/UIDatePicker used by DatePicker/TimePicker), it
early-returns without clearing. DatePicker and TimePicker didn't have
their own MapBackground registered for iOS/MacCatalyst (only
Android/Windows had it), so they fell through to this broken path.

### Description of Change

**Platform handler updates:**

* Added internal `MapBackground` methods to both `DatePickerHandler` and
`TimePickerHandler` for iOS and MacCatalyst, which remove the background
layer and reset the background color when the `Background` property is
set to `null`.
* Updated property mappers in `DatePickerHandler.cs` and
`TimePickerHandler.cs` to include the new `MapBackground` mapping for
iOS and MacCatalyst.

**Test coverage:**

* Added a new test case page (`Issue36933`) that allows toggling the
background of `DatePicker` and `TimePicker` between a color and `null`
at runtime.
* Added a UI test verifying that the background is cleared when set to
`null` and can be set to a new color.

**Code maintenance:**

* Added missing `using Microsoft.Maui.Graphics;` directives to relevant
files for background color handling.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36933

### Tested the behavior in the following platforms
 
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

### Output
 
| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2">
| <video
src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4">
|










<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Sep 3, 2026
… when set to null at runtime (#36934)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details:

- DatePicker and TimePicker Background set to null at runtime does not
clear the background on iOS and MacCatalyst. The previously set
background color/brush remains visible.

### Root Cause of the issue:

- On iOS, ViewExtensions.UpdateBackground() has a type guard (line
84-89) that only clears BackgroundColor for LayoutView or ContentView
when paint is null — for all other UIView subclasses (including
UITextField/UIDatePicker used by DatePicker/TimePicker), it
early-returns without clearing. DatePicker and TimePicker didn't have
their own MapBackground registered for iOS/MacCatalyst (only
Android/Windows had it), so they fell through to this broken path.

### Description of Change

**Platform handler updates:**

* Added internal `MapBackground` methods to both `DatePickerHandler` and
`TimePickerHandler` for iOS and MacCatalyst, which remove the background
layer and reset the background color when the `Background` property is
set to `null`.
* Updated property mappers in `DatePickerHandler.cs` and
`TimePickerHandler.cs` to include the new `MapBackground` mapping for
iOS and MacCatalyst.

**Test coverage:**

* Added a new test case page (`Issue36933`) that allows toggling the
background of `DatePicker` and `TimePicker` between a color and `null`
at runtime.
* Added a UI test verifying that the background is cleared when set to
`null` and can be set to a new color.

**Code maintenance:**

* Added missing `using Microsoft.Maui.Graphics;` directives to relevant
files for background color handling.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36933

### Tested the behavior in the following platforms
 
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

### Output
 
| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2">
| <video
src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4">
|










<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Sep 4, 2026
… when set to null at runtime (#36934)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details:

- DatePicker and TimePicker Background set to null at runtime does not
clear the background on iOS and MacCatalyst. The previously set
background color/brush remains visible.

### Root Cause of the issue:

- On iOS, ViewExtensions.UpdateBackground() has a type guard (line
84-89) that only clears BackgroundColor for LayoutView or ContentView
when paint is null — for all other UIView subclasses (including
UITextField/UIDatePicker used by DatePicker/TimePicker), it
early-returns without clearing. DatePicker and TimePicker didn't have
their own MapBackground registered for iOS/MacCatalyst (only
Android/Windows had it), so they fell through to this broken path.

### Description of Change

**Platform handler updates:**

* Added internal `MapBackground` methods to both `DatePickerHandler` and
`TimePickerHandler` for iOS and MacCatalyst, which remove the background
layer and reset the background color when the `Background` property is
set to `null`.
* Updated property mappers in `DatePickerHandler.cs` and
`TimePickerHandler.cs` to include the new `MapBackground` mapping for
iOS and MacCatalyst.

**Test coverage:**

* Added a new test case page (`Issue36933`) that allows toggling the
background of `DatePicker` and `TimePicker` between a color and `null`
at runtime.
* Added a UI test verifying that the background is cleared when set to
`null` and can be set to a new color.

**Code maintenance:**

* Added missing `using Microsoft.Maui.Graphics;` directives to relevant
files for background color handling.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36933

### Tested the behavior in the following platforms
 
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

### Output
 
| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2">
| <video
src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4">
|










<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Sep 6, 2026
… when set to null at runtime (#36934)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details:

- DatePicker and TimePicker Background set to null at runtime does not
clear the background on iOS and MacCatalyst. The previously set
background color/brush remains visible.

### Root Cause of the issue:

- On iOS, ViewExtensions.UpdateBackground() has a type guard (line
84-89) that only clears BackgroundColor for LayoutView or ContentView
when paint is null — for all other UIView subclasses (including
UITextField/UIDatePicker used by DatePicker/TimePicker), it
early-returns without clearing. DatePicker and TimePicker didn't have
their own MapBackground registered for iOS/MacCatalyst (only
Android/Windows had it), so they fell through to this broken path.

### Description of Change

**Platform handler updates:**

* Added internal `MapBackground` methods to both `DatePickerHandler` and
`TimePickerHandler` for iOS and MacCatalyst, which remove the background
layer and reset the background color when the `Background` property is
set to `null`.
* Updated property mappers in `DatePickerHandler.cs` and
`TimePickerHandler.cs` to include the new `MapBackground` mapping for
iOS and MacCatalyst.

**Test coverage:**

* Added a new test case page (`Issue36933`) that allows toggling the
background of `DatePicker` and `TimePicker` between a color and `null`
at runtime.
* Added a UI test verifying that the background is cleared when set to
`null` and can be set to a new color.

**Code maintenance:**

* Added missing `using Microsoft.Maui.Graphics;` directives to relevant
files for background color handling.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36933

### Tested the behavior in the following platforms
 
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

### Output
 
| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2">
| <video
src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4">
|










<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Sep 7, 2026
… when set to null at runtime (#36934)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details:

- DatePicker and TimePicker Background set to null at runtime does not
clear the background on iOS and MacCatalyst. The previously set
background color/brush remains visible.

### Root Cause of the issue:

- On iOS, ViewExtensions.UpdateBackground() has a type guard (line
84-89) that only clears BackgroundColor for LayoutView or ContentView
when paint is null — for all other UIView subclasses (including
UITextField/UIDatePicker used by DatePicker/TimePicker), it
early-returns without clearing. DatePicker and TimePicker didn't have
their own MapBackground registered for iOS/MacCatalyst (only
Android/Windows had it), so they fell through to this broken path.

### Description of Change

**Platform handler updates:**

* Added internal `MapBackground` methods to both `DatePickerHandler` and
`TimePickerHandler` for iOS and MacCatalyst, which remove the background
layer and reset the background color when the `Background` property is
set to `null`.
* Updated property mappers in `DatePickerHandler.cs` and
`TimePickerHandler.cs` to include the new `MapBackground` mapping for
iOS and MacCatalyst.

**Test coverage:**

* Added a new test case page (`Issue36933`) that allows toggling the
background of `DatePicker` and `TimePicker` between a color and `null`
at runtime.
* Added a UI test verifying that the background is cleared when set to
`null` and can be set to a new color.

**Code maintenance:**

* Added missing `using Microsoft.Maui.Graphics;` directives to relevant
files for background color handling.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36933

### Tested the behavior in the following platforms
 
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

### Output
 
| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2">
| <video
src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4">
|










<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Sep 7, 2026
… when set to null at runtime (#36934)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details:

- DatePicker and TimePicker Background set to null at runtime does not
clear the background on iOS and MacCatalyst. The previously set
background color/brush remains visible.

### Root Cause of the issue:

- On iOS, ViewExtensions.UpdateBackground() has a type guard (line
84-89) that only clears BackgroundColor for LayoutView or ContentView
when paint is null — for all other UIView subclasses (including
UITextField/UIDatePicker used by DatePicker/TimePicker), it
early-returns without clearing. DatePicker and TimePicker didn't have
their own MapBackground registered for iOS/MacCatalyst (only
Android/Windows had it), so they fell through to this broken path.

### Description of Change

**Platform handler updates:**

* Added internal `MapBackground` methods to both `DatePickerHandler` and
`TimePickerHandler` for iOS and MacCatalyst, which remove the background
layer and reset the background color when the `Background` property is
set to `null`.
* Updated property mappers in `DatePickerHandler.cs` and
`TimePickerHandler.cs` to include the new `MapBackground` mapping for
iOS and MacCatalyst.

**Test coverage:**

* Added a new test case page (`Issue36933`) that allows toggling the
background of `DatePicker` and `TimePicker` between a color and `null`
at runtime.
* Added a UI test verifying that the background is cleared when set to
`null` and can be set to a new color.

**Code maintenance:**

* Added missing `using Microsoft.Maui.Graphics;` directives to relevant
files for background color handling.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36933

### Tested the behavior in the following platforms
 
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

### Output
 
| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2">
| <video
src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4">
|










<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Sep 8, 2026
… when set to null at runtime (#36934)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details:

- DatePicker and TimePicker Background set to null at runtime does not
clear the background on iOS and MacCatalyst. The previously set
background color/brush remains visible.

### Root Cause of the issue:

- On iOS, ViewExtensions.UpdateBackground() has a type guard (line
84-89) that only clears BackgroundColor for LayoutView or ContentView
when paint is null — for all other UIView subclasses (including
UITextField/UIDatePicker used by DatePicker/TimePicker), it
early-returns without clearing. DatePicker and TimePicker didn't have
their own MapBackground registered for iOS/MacCatalyst (only
Android/Windows had it), so they fell through to this broken path.

### Description of Change

**Platform handler updates:**

* Added internal `MapBackground` methods to both `DatePickerHandler` and
`TimePickerHandler` for iOS and MacCatalyst, which remove the background
layer and reset the background color when the `Background` property is
set to `null`.
* Updated property mappers in `DatePickerHandler.cs` and
`TimePickerHandler.cs` to include the new `MapBackground` mapping for
iOS and MacCatalyst.

**Test coverage:**

* Added a new test case page (`Issue36933`) that allows toggling the
background of `DatePicker` and `TimePicker` between a color and `null`
at runtime.
* Added a UI test verifying that the background is cleared when set to
`null` and can be set to a new color.

**Code maintenance:**

* Added missing `using Microsoft.Maui.Graphics;` directives to relevant
files for background color handling.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36933

### Tested the behavior in the following platforms
 
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

### Output
 
| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2">
| <video
src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4">
|










<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Sep 8, 2026
… when set to null at runtime (#36934)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details:

- DatePicker and TimePicker Background set to null at runtime does not
clear the background on iOS and MacCatalyst. The previously set
background color/brush remains visible.

### Root Cause of the issue:

- On iOS, ViewExtensions.UpdateBackground() has a type guard (line
84-89) that only clears BackgroundColor for LayoutView or ContentView
when paint is null — for all other UIView subclasses (including
UITextField/UIDatePicker used by DatePicker/TimePicker), it
early-returns without clearing. DatePicker and TimePicker didn't have
their own MapBackground registered for iOS/MacCatalyst (only
Android/Windows had it), so they fell through to this broken path.

### Description of Change

**Platform handler updates:**

* Added internal `MapBackground` methods to both `DatePickerHandler` and
`TimePickerHandler` for iOS and MacCatalyst, which remove the background
layer and reset the background color when the `Background` property is
set to `null`.
* Updated property mappers in `DatePickerHandler.cs` and
`TimePickerHandler.cs` to include the new `MapBackground` mapping for
iOS and MacCatalyst.

**Test coverage:**

* Added a new test case page (`Issue36933`) that allows toggling the
background of `DatePicker` and `TimePicker` between a color and `null`
at runtime.
* Added a UI test verifying that the background is cleared when set to
`null` and can be set to a new color.

**Code maintenance:**

* Added missing `using Microsoft.Maui.Graphics;` directives to relevant
files for background color handling.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36933

### Tested the behavior in the following platforms
 
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

### Output
 
| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2">
| <video
src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4">
|










<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Sep 9, 2026
… when set to null at runtime (#36934)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details:

- DatePicker and TimePicker Background set to null at runtime does not
clear the background on iOS and MacCatalyst. The previously set
background color/brush remains visible.

### Root Cause of the issue:

- On iOS, ViewExtensions.UpdateBackground() has a type guard (line
84-89) that only clears BackgroundColor for LayoutView or ContentView
when paint is null — for all other UIView subclasses (including
UITextField/UIDatePicker used by DatePicker/TimePicker), it
early-returns without clearing. DatePicker and TimePicker didn't have
their own MapBackground registered for iOS/MacCatalyst (only
Android/Windows had it), so they fell through to this broken path.

### Description of Change

**Platform handler updates:**

* Added internal `MapBackground` methods to both `DatePickerHandler` and
`TimePickerHandler` for iOS and MacCatalyst, which remove the background
layer and reset the background color when the `Background` property is
set to `null`.
* Updated property mappers in `DatePickerHandler.cs` and
`TimePickerHandler.cs` to include the new `MapBackground` mapping for
iOS and MacCatalyst.

**Test coverage:**

* Added a new test case page (`Issue36933`) that allows toggling the
background of `DatePicker` and `TimePicker` between a color and `null`
at runtime.
* Added a UI test verifying that the background is cleared when set to
`null` and can be set to a new color.

**Code maintenance:**

* Added missing `using Microsoft.Maui.Graphics;` directives to relevant
files for background color handling.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36933

### Tested the behavior in the following platforms
 
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

### Output
 
| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2">
| <video
src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4">
|










<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Sep 9, 2026
… when set to null at runtime (#36934)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details:

- DatePicker and TimePicker Background set to null at runtime does not
clear the background on iOS and MacCatalyst. The previously set
background color/brush remains visible.

### Root Cause of the issue:

- On iOS, ViewExtensions.UpdateBackground() has a type guard (line
84-89) that only clears BackgroundColor for LayoutView or ContentView
when paint is null — for all other UIView subclasses (including
UITextField/UIDatePicker used by DatePicker/TimePicker), it
early-returns without clearing. DatePicker and TimePicker didn't have
their own MapBackground registered for iOS/MacCatalyst (only
Android/Windows had it), so they fell through to this broken path.

### Description of Change

**Platform handler updates:**

* Added internal `MapBackground` methods to both `DatePickerHandler` and
`TimePickerHandler` for iOS and MacCatalyst, which remove the background
layer and reset the background color when the `Background` property is
set to `null`.
* Updated property mappers in `DatePickerHandler.cs` and
`TimePickerHandler.cs` to include the new `MapBackground` mapping for
iOS and MacCatalyst.

**Test coverage:**

* Added a new test case page (`Issue36933`) that allows toggling the
background of `DatePicker` and `TimePicker` between a color and `null`
at runtime.
* Added a UI test verifying that the background is cleared when set to
`null` and can be set to a new color.

**Code maintenance:**

* Added missing `using Microsoft.Maui.Graphics;` directives to relevant
files for background color handling.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36933

### Tested the behavior in the following platforms
 
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

### Output
 
| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2">
| <video
src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4">
|










<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS/MacCatalyst] DatePicker and TimePicker Background is not cleared when set to null at runtime

6 participants