-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Windows] Fix for Picker CharacterSpacing Not Being Applied to Title and Dropdown Items #30612
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
Merged
kubaflo
merged 8 commits into
dotnet:inflight/current
from
SyedAbdulAzeemSF4852:fix-30464
May 30, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4d01054
[Windows] Fix for Picker CharacterSpacing property not being applied …
SyedAbdulAzeemSF4852 fc2140d
Have added the test case along with snapshots for both Android and iO…
SyedAbdulAzeemSF4852 c7bf030
Added baseline snapshots for Windows and macOS
SyedAbdulAzeemSF4852 e3c0cd5
Update Resources.xaml
SyedAbdulAzeemSF4852 3362869
more refactor
SyedAbdulAzeemSF4852 6b625c0
Modified the fix
SyedAbdulAzeemSF4852 86e8d3e
Modify Picker CharacterSpacing fix on Windows
SyedAbdulAzeemSF4852 06ee8c9
Update Windows snapshot baseline
SyedAbdulAzeemSF4852 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+60.6 KB
....Android.Tests/snapshots/android/ValidatePickerTitleAndItemCharacterSpacing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| namespace Controls.TestCases.HostApp.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 30464, "The CharacterSpacing property on the Picker control is not applied to the title or the items", PlatformAffected.UWP)] | ||
| public class Issue30464 : ContentPage | ||
| { | ||
| public Issue30464() | ||
| { | ||
| Picker pickerTitleCharacterSpacing = new Picker | ||
| { | ||
| Title = "Select an item", | ||
| }; | ||
| pickerTitleCharacterSpacing.Items.Add("Item 1"); | ||
|
|
||
| Picker pickerItemCharacterSpacing = new Picker | ||
| { | ||
| ItemsSource = new List<string> { "Item 1", "Item 2" }, | ||
| SelectedIndex = 1 | ||
| }; | ||
|
|
||
| Button applyCharacterSpacingBtn = new Button | ||
| { | ||
| Text = "Apply character spacing", | ||
| AutomationId = "Issue30464Btn" | ||
| }; | ||
|
|
||
| applyCharacterSpacingBtn.Clicked += (sender, e) => | ||
| { | ||
| pickerTitleCharacterSpacing.CharacterSpacing = 14; | ||
| pickerItemCharacterSpacing.CharacterSpacing = 14; | ||
| }; | ||
|
|
||
| Label descriptionLabel = new Label | ||
| { | ||
| AutomationId = "Issue30464DescriptionLabel", | ||
| Text = "The test case passes only if character spacing is correctly applied to both the Picker title and items, and is maintained after selecting a different item; otherwise, it fails.", | ||
| }; | ||
|
|
||
| Picker pickerSelectionChange = new Picker | ||
| { | ||
| ItemsSource = new List<string> { "Item 1", "Item 2" }, | ||
| SelectedIndex = 0, | ||
| CharacterSpacing = 14, | ||
| AutomationId = "Issue30464SelectionChangePicker" | ||
| }; | ||
|
|
||
| Button changeSelectionBtn = new Button | ||
| { | ||
| Text = "Change selection", | ||
| AutomationId = "Issue30464ChangeSelectionBtn" | ||
| }; | ||
| changeSelectionBtn.Clicked += (sender, e) => | ||
| { | ||
| pickerSelectionChange.SelectedIndex = 1; | ||
| }; | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| Spacing = 20, | ||
| Padding = 20, | ||
| Children = | ||
| { | ||
| pickerTitleCharacterSpacing, | ||
| pickerItemCharacterSpacing, | ||
| applyCharacterSpacingBtn, | ||
| pickerSelectionChange, | ||
| changeSelectionBtn, | ||
| descriptionLabel, | ||
| } | ||
| }; | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30464.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST // PR Link - https://github.com/dotnet/maui/pull/34974 | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue30464 : _IssuesUITest | ||
| { | ||
| public Issue30464(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "The CharacterSpacing property on the Picker control is not applied to the title or the items"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Picker)] | ||
| public void ValidatePickerTitleAndItemCharacterSpacing() | ||
| { | ||
| App.WaitForElement("Issue30464DescriptionLabel"); | ||
| App.Tap("Issue30464Btn"); | ||
| App.Tap("Issue30464ChangeSelectionBtn"); | ||
| VerifyScreenshot(); | ||
| } | ||
| } | ||
| #endif |
Binary file added
BIN
+16.5 KB
...es.WinUI.Tests/snapshots/windows/ValidatePickerTitleAndItemCharacterSpacing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Core/src/Platform/Windows/CharacterSpacingConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| using System; | ||
|
|
||
| namespace Microsoft.Maui.Platform; | ||
|
|
||
| internal sealed partial class CharacterSpacingConverter : UI.Xaml.Data.IValueConverter | ||
| { | ||
| public object Convert(object value, Type targetType, object parameter, string language) | ||
| { | ||
| if (value is double characterSpacing) | ||
| { | ||
| return characterSpacing.ToEm(); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| public object ConvertBack(object value, Type targetType, object parameter, string language) | ||
| { | ||
| throw new NotSupportedException(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |||||
| <DataTemplate x:Key="ComboBoxHeader"> | ||||||
| <TextBlock | ||||||
| Text="{Binding Title}" | ||||||
| CharacterSpacing="{Binding Path=CharacterSpacing, ElementName=HeaderContentPresenter}" | ||||||
| CharacterSpacing="{Binding CharacterSpacing, Converter={StaticResource CharacterSpacingConverter}}" | ||||||
|
||||||
| CharacterSpacing="{Binding CharacterSpacing, Converter={StaticResource CharacterSpacingConverter}}" | |
| CharacterSpacing="{Binding CharacterSpacing, ElementName=HeaderContentPresenter, Converter={StaticResource CharacterSpacingConverter}}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[moderate] Logic and Correctness - This reapply path only runs when
CharacterSpacing > 0, butCharacterSpacinghas no non-negative validation and the other Windows text controls applyCharacterSpacing.ToEm()directly. A Picker using negative character spacing can updateComboBox.CharacterSpacing, then lose that value after selection/dropdown lifecycle because the selectedTextBlockis not re-stamped here or in the matching dropdown-closed path at line 177. Apply the current converted value unconditionally so zero/negative values are preserved consistently.