KEMBAR78
[Windows] Fixed runtime update issue for SearchBar PlaceholderColor and BackgroundColor by Tamilarasan-Paranthaman · Pull Request #29965 · dotnet/maui · GitHub
Skip to content

Conversation

Tamilarasan-Paranthaman
Copy link
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!

Root Cause of the issue

  • On the Windows platform, when SearchBar.PlaceholderColor or BackgroundColor is updated at runtime, and the corresponding resource keys are correctly modified in the resource dictionary. However, the control does not automatically refresh its appearance because a call to RefreshThemeResources() was missing. As a result, the UI did not reflect the updated colors.

Description of Change

  • Added a call to the control’s RefreshThemeResources() method after updating the resource dictionary, ensuring the updated theme resources are applied to the control. This change ensures that runtime updates to PlaceholderColor or BackgroundColor are immediately reflected in the UI on the Windows platform.

Issues Fixed

Fixes #29962

Tested the behaviour in the following platforms

  • Windows
  • iOS
  • Mac
  • Android

Screenshot

Before Fix After Fix
Before-Fix-SB.mp4
After-Fix-SB.mp4

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 12, 2025
@dotnet-policy-service
Copy link
Contributor

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

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jun 12, 2025
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman marked this pull request as ready for review June 12, 2025 14:38
@Copilot Copilot AI review requested due to automatic review settings June 12, 2025 14:38
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman requested a review from a team as a code owner June 12, 2025 14:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that runtime updates to a SearchBar’s PlaceholderColor and BackgroundColor on Windows are immediately applied by invoking RefreshThemeResources() after modifying the resource dictionary.

  • Added a new overload of UpdateColors that accepts the control and calls RefreshThemeResources()
  • Updated UpdateBackground and UpdatePlaceholderColor to use the new UpdateColors signature
  • Standardized null checks and added braces for clarity; refined UpdateMaxLength logic to always set read-only state

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

File Description
src/Core/src/Platform/Windows/SearchBarExtensions.cs Refactored color update helpers, ensured theme resources are refreshed after resource updates
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29962.cs Added a UI test that taps the button and verifies placeholder and background colors at runtime
src/Controls/tests/TestCases.HostApp/Issues/Issue29962.cs Added a sample page with a SearchBar and button to change colors, exposing ColorChangeButton ID
Comments suppressed due to low confidence (4)

src/Core/src/Platform/Windows/SearchBarExtensions.cs:10

  • The _backgroundColorKeys field was previously private; consider restoring the private modifier to limit its visibility and follow encapsulation best practices.
static readonly string[] _backgroundColorKeys =

src/Core/src/Platform/Windows/SearchBarExtensions.cs:38

  • The _placeholderForegroundColorKeys field is now internal; it should remain private unless access from other classes within the assembly is required.
static readonly string[] _placeholderForegroundColorKeys =

src/Core/src/Platform/Windows/SearchBarExtensions.cs:56

  • Similarly, _foregroundColorKeys should be declared private static readonly to restrict its scope to this class.
static readonly string[] _foregroundColorKeys =

src/Core/src/Platform/Windows/SearchBarExtensions.cs:82

  • The UpdateColors helper method lost its visibility modifier—consider making it private static to avoid unintended external usage.
static void UpdateColors(AutoSuggestBox platformControl, string[] keys, Brush? brush)

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen PureWeen changed the base branch from main to inflight/current June 16, 2025 17:11
@PureWeen PureWeen merged commit fc59094 into dotnet:inflight/current Jun 16, 2025
74 of 79 checks passed
PureWeen pushed a commit that referenced this pull request Jun 21, 2025
…nd BackgroundColor (#29965)

* Fixed SearchBar color issues

* Added test sample

* Added Windows and Mac snapshots
PureWeen pushed a commit that referenced this pull request Jun 25, 2025
…nd BackgroundColor (#29965)

* Fixed SearchBar color issues

* Added test sample

* Added Windows and Mac snapshots
PureWeen pushed a commit that referenced this pull request Jun 25, 2025
…nd BackgroundColor (#29965)

* Fixed SearchBar color issues

* Added test sample

* Added Windows and Mac snapshots
github-actions bot pushed a commit that referenced this pull request Jun 26, 2025
…nd BackgroundColor (#29965)

* Fixed SearchBar color issues

* Added test sample

* Added Windows and Mac snapshots
github-actions bot pushed a commit that referenced this pull request Jun 26, 2025
…nd BackgroundColor (#29965)

* Fixed SearchBar color issues

* Added test sample

* Added Windows and Mac snapshots
PureWeen pushed a commit that referenced this pull request Jun 27, 2025
…nd BackgroundColor (#29965)

* Fixed SearchBar color issues

* Added test sample

* Added Windows and Mac snapshots
github-actions bot pushed a commit that referenced this pull request Jun 27, 2025
…nd BackgroundColor (#29965)

* Fixed SearchBar color issues

* Added test sample

* Added Windows and Mac snapshots
PureWeen pushed a commit that referenced this pull request Jun 27, 2025
…nd BackgroundColor (#29965)

* Fixed SearchBar color issues

* Added test sample

* Added Windows and Mac snapshots
PureWeen added a commit that referenced this pull request Jun 28, 2025
For more information about inflight process check
https://github.com/dotnet/maui/wiki/Inflight-Branch-Process

# .NET MAUI Release Notes - Inflight/Candidate Branch

## What's Changed

### MAUI Product Fixes
* [iOS] CarouselView with CarouselViewHandler2 make app crash when
Loop="False" and user scroll to the last position - fixes #26863 by
@kubaflo in #26868
* Fixes Setting BackgroundColor to null does not actually changes
BackgroundColor - fixes #22914 and #19576 by @jgonzalez-gft in
#22917
* Fixed the picker title's color - fixes #16737 by @kubaflo in
#23075
* [android] Fallback to default icons in SearchHandler by @aheubusch in
#25067
* ScrollView's Background on iOS - fixes #24016 by @kubaflo in
#25541
* [iOS] Enabled MultiTouch Support for Handling Multi-Touch Points in
GraphicsView - fixes #29461 by @prakashKannanSf3972 in
#29895
* Optimize converters for GridLength, ColumnDefinition, and
RowDefinition - performance improvement by @emiller in
#20048
* Add defensive IsAlive check to Android ViewExtensions.OnUnloaded -
fixes #28051 by @jfversluis in #29934
* [Windows] Fixed runtime update issue for SearchBar PlaceholderColor
and BackgroundColor - fixes #29962 by @Tamilarasan-Paranthaman in
#29965
* Weak subscription to CanExecuteChange events - fixes #16124 by
@sneumaier in #29837
* [iOS, Mac] Fix for downsized image retaining original dimensions in
GraphicsView - fixes #30006 by @SyedAbdulAzeemSF4852 in
#30007
* [Android] Prevent Picker from Gaining Focus on Touch - fixes #19739,
#8546, #13503, #24862, #28121, #21704, #15394 by @bhavanesh2001 in
#29068
* Fix CV1 GridItemsLayout centering single item AND Fix Empty view not
resizing when bounds change - fixes #29595, #29634 by @albyrock87 in
#29639

### Testing
* [Testing] Feature Matrix UITest Cases for Button by @TamilarasanSF4853
in #29803
* [Testing] Feature matrix UITest Cases for BoxView Control by
@HarishKumarSF4517 in #29808
* [Testing] Enable HandlerDoesNotLeak for Button and ProgressBar by
@bhavanesh2001 in #29896
* [Testing] Add Validation Test For Issue28051 On Android by
@prakashKannanSf3972 in #30026
* [Testing] Fixed Test case failure in PR 30115 - [2025/06/23] Candidate
by @HarishKumarSF4517 in #30136

### Dependency Updates
* Bump to 1.7.250606001 of WindowsAppSDK by @sneumaier in
#29915

### Housekeeping
* [housekeeping] Update namespaces in HostApp and Shared tests projects
by @bhavanesh2001 in #29904
* Update SetterSpecificity.cs Remove Extra Line From Bad Merge by
@sneumaier in #29987
* Revert - Fixed the Label not sized correctly on Android by @Ahamed-Ali
in #30023
* Revert "Fixes Setting BackgroundColor to null does not actually
changes BackgroundColor #22914 (#22917)" by @mattleibow in
#30031
* [create-pull-request] automated change by @github-actions[bot] in
#30019
* [create-pull-request] automated change by @github-actions[bot] in
#30043
* [create-pull-request] automated change by @github-actions[bot] in
#30078
* Update Controls.TestCases.HostApp.csproj by @HarishKumarSF4517 in
#30124

## New Contributors
* @albyrock87 made their first contribution in
#29639
* @SyedAbdulAzeemSF4852 made their first contribution in
#30007
* @emiller made their first contribution in
#20048
* @jgonzalez-gft made their first contribution in
#22917
* @aheubusch made their first contribution in
#25067

**Full Changelog**:
https://github.com/dotnet/maui/compare/main..inflight/candidate
@github-actions github-actions bot locked and limited conversation to collaborators Jul 17, 2025
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman deleted the SearchBar-Color-Issues branch September 24, 2025 10:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-searchbar SearchBar control community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] SearchBar PlaceholderColor and BackgroundColor not updating at runtime

4 participants