Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
946931b
replace Header with PlaceholderText for Title property of Picker on W…
mhrastegari Nov 19, 2025
95cffd0
add UI Tests
mhrastegari Apr 19, 2026
2ae9b2a
remove dead ComboBox styles
mhrastegari Apr 20, 2026
06c890c
add UpdateTitleColor to PickerExtensions
mhrastegari Apr 20, 2026
c733de0
add more tests
mhrastegari Apr 20, 2026
93c2a47
update unshipped public API text
mhrastegari Apr 29, 2026
c7fc5ab
Merge branch 'main' into 32723-replace-header-with-placeholder-on-win…
mhrastegari Apr 29, 2026
61cf4b9
add more tests for TitleColor
mhrastegari May 3, 2026
c3ff067
add CharacterSpacing test
mhrastegari May 3, 2026
179a333
resolve MauiBot review comments
mhrastegari May 16, 2026
83925c0
Merge branch 'net11.0' into 32723-replace-header-with-placeholder-on-…
kubaflo May 25, 2026
142d93a
fix CharacterSpacing test
mhrastegari Jun 1, 2026
e2500bd
resolve review comments
mhrastegari Jun 20, 2026
68e2e2a
add more tests
mhrastegari Jun 22, 2026
8d146bc
add Appium UI tests
mhrastegari Jun 24, 2026
6b9d640
Merge branch 'net11.0' into 32723-replace-header-with-placeholder-on-…
kubaflo Jun 24, 2026
798091c
fix conflicts
mhrastegari Jul 6, 2026
c0fac3f
Merge branch 'net11.0' into 32723-replace-header-with-placeholder-on-…
mhrastegari Jul 6, 2026
774396f
resolve review comments
mhrastegari Jul 14, 2026
7f211cd
resolve review comments
mhrastegari Jul 20, 2026
cc23b5b
update screenshots
mhrastegari Jul 20, 2026
d47a945
resolve review comments
mhrastegari Jul 21, 2026
c89e2e3
resolve review comments
mhrastegari Jul 24, 2026
3c02076
Merge branch 'net11.0' into 32723-replace-header-with-placeholder-on-…
mhrastegari Jul 26, 2026
7c95d32
resolve review comments
mhrastegari Jul 26, 2026
8cd9286
update screenshots
mhrastegari Jul 26, 2026
317960f
update screenshots
mhrastegari Jul 30, 2026
2c95990
Merge branch 'net11.0' into 32723-replace-header-with-placeholder-on-…
kubaflo Aug 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
233 changes: 233 additions & 0 deletions src/Controls/tests/DeviceTests/Elements/Picker/PickerTests.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Platform;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Xunit;
using WSolidColorBrush = Microsoft.UI.Xaml.Media.SolidColorBrush;

namespace Microsoft.Maui.DeviceTests
{
Expand Down Expand Up @@ -56,6 +58,237 @@ public async Task VerticalOptionsInitializesCorrectly()
await InvokeOnMainThreadAsync(() => Assert.Equal(UI.Xaml.VerticalAlignment.Bottom, GetPlatformVerticalOptions(handler.PlatformView)));
}

[Fact(DisplayName = "Title does not set ComboBox Header")]
public async Task TitleDoesNotSetHeader()
{
var picker = new Picker()
{
Title = "Select Option",
ItemsSource = new ObservableCollection<string>()
{
"Item 1",
"Item 2"
}
};

var handler = await CreateHandlerAsync<PickerHandler>(picker);

await InvokeOnMainThreadAsync(() =>
{
Assert.Null(handler.PlatformView.Header);
Assert.Equal(DependencyProperty.UnsetValue, handler.PlatformView.ReadLocalValue(ComboBox.HeaderTemplateProperty));
});
}

[Fact(DisplayName = "Title maps to PlaceholderText")]
public async Task TitleMapsToPlaceholderText()
{
var picker = new Picker()
{
Title = "Select Option",
ItemsSource = new ObservableCollection<string>()
{
"Item 1",
"Item 2"
}
};

var handler = await CreateHandlerAsync<PickerHandler>(picker);

await InvokeOnMainThreadAsync(() =>
{
Assert.Equal("Select Option", handler.PlatformView.PlaceholderText);
});
}

[Fact(DisplayName = "Null title maps to empty PlaceholderText")]
public async Task NullTitleMapsToEmptyPlaceholderText()
{
var picker = new Picker()
{
Title = null,
ItemsSource = new ObservableCollection<string>()
{
"Item 1",
"Item 2"
}
};

var handler = await CreateHandlerAsync<PickerHandler>(picker);

await InvokeOnMainThreadAsync(() =>
{
Assert.Equal(string.Empty, handler.PlatformView.PlaceholderText);
});
}

[Fact(DisplayName = "Empty title maps to empty PlaceholderText")]
public async Task EmptyTitleMapsToEmptyPlaceholderText()
{
var picker = new Picker()
{
Title = string.Empty,
ItemsSource = new ObservableCollection<string>()
{
"Item 1",
"Item 2"
}
};

var handler = await CreateHandlerAsync<PickerHandler>(picker);

await InvokeOnMainThreadAsync(() =>
{
Assert.Equal(string.Empty, handler.PlatformView.PlaceholderText);
});
}

[Fact(DisplayName = "TitleColor maps to PlaceholderForeground")]
public async Task TitleColorMapsToPlaceholderForeground()
{
var picker = new Picker()
{
Title = "Select Option",
TitleColor = Colors.Red,
ItemsSource = new ObservableCollection<string>()
{
"Item 1",
"Item 2"
}
};

var handler = await CreateHandlerAsync<PickerHandler>(picker);

await InvokeOnMainThreadAsync(() =>
{
var placeholderBrush = Assert.IsType<WSolidColorBrush>(handler.PlatformView.PlaceholderForeground);
Assert.Equal(Colors.Red, placeholderBrush.Color.ToColor());
});
Comment thread
mhrastegari marked this conversation as resolved.
Resolved
}
Comment thread
mhrastegari marked this conversation as resolved.
Resolved

[Fact(DisplayName = "Null TitleColor clears local PlaceholderForeground")]
public async Task NullTitleColorClearsPlaceholderForegroundLocalValue()
{
var picker = new Picker()
{
Title = "Select Option",
TitleColor = Colors.Red,
ItemsSource = new ObservableCollection<string>()
{
"Item 1",
"Item 2"
}
};

var handler = await CreateHandlerAsync<PickerHandler>(picker);

await InvokeOnMainThreadAsync(() =>
{
Assert.IsType<WSolidColorBrush>(handler.PlatformView.PlaceholderForeground);

picker.ClearValue(Picker.TitleColorProperty);

Assert.Equal(DependencyProperty.UnsetValue, handler.PlatformView.ReadLocalValue(ComboBox.PlaceholderForegroundProperty));
});
}

[Fact(DisplayName = "Title and TitleColor update after handler creation")]
public async Task TitleAndTitleColorUpdateAfterHandlerCreation()
{
var picker = new Picker()
{
Title = "First",
TitleColor = Colors.Red,
ItemsSource = new ObservableCollection<string>()
{
"Item 1",
"Item 2"
}
};

var handler = await CreateHandlerAsync<PickerHandler>(picker);

await InvokeOnMainThreadAsync(() =>
{
picker.Title = "Second";
Assert.Equal("Second", handler.PlatformView.PlaceholderText);

picker.TitleColor = Colors.Blue;
var brush = Assert.IsType<WSolidColorBrush>(handler.PlatformView.PlaceholderForeground);
Assert.Equal(Colors.Blue, brush.Color.ToColor());
});
}

[Fact(DisplayName = "CharacterSpacing applies to placeholder TextBlock when Title is set")]
public async Task CharacterSpacingAppliesToPlaceholderWithTitle()
{
const string title = "Select Option";
const double characterSpacingPt = 8d;
var expectedEm = characterSpacingPt.ToEm();

var picker = new Picker()
{
Title = title,
CharacterSpacing = characterSpacingPt,
ItemsSource = new ObservableCollection<string>()
{
"Item 1",
"Item 2"
},
WidthRequest = 200,
HeightRequest = 48
};

await AttachAndRun<PickerHandler>(picker, handler =>
{
var platformView = handler.PlatformView;

Assert.Equal(title, platformView.PlaceholderText);
Assert.Equal(expectedEm, platformView.CharacterSpacing);

var placeholderTextBlock = platformView.GetDescendantByName<TextBlock>("PlaceholderTextBlock");
Assert.NotNull(placeholderTextBlock);
Assert.Equal(title, placeholderTextBlock.Text);
Assert.Equal(expectedEm, placeholderTextBlock.CharacterSpacing);
Comment thread
mhrastegari marked this conversation as resolved.
Resolved
});
}

[Fact(DisplayName = "CharacterSpacing updates on placeholder TextBlock after handler creation")]
public async Task CharacterSpacingUpdatesAfterHandlerCreation()
{
const string title = "Select Option";
const double initialSpacingPt = 8d;
const double updatedSpacingPt = 16d;
var initialEm = initialSpacingPt.ToEm();
var updatedEm = updatedSpacingPt.ToEm();

var picker = new Picker()
{
Title = title,
CharacterSpacing = initialSpacingPt,
ItemsSource = new ObservableCollection<string>()
{
"Item 1",
"Item 2"
},
WidthRequest = 200,
HeightRequest = 48
};

await AttachAndRun<PickerHandler>(picker, handler =>
{
var platformView = handler.PlatformView;
var placeholderTextBlock = platformView.GetDescendantByName<TextBlock>("PlaceholderTextBlock");
Assert.NotNull(placeholderTextBlock);
Assert.Equal(initialEm, placeholderTextBlock.CharacterSpacing);

picker.CharacterSpacing = updatedSpacingPt;

Assert.Equal(updatedEm, platformView.CharacterSpacing);
Assert.Equal(updatedEm, placeholderTextBlock.CharacterSpacing);
});
}

protected Task<string> GetPlatformControlText(ComboBox platformView)
{
return InvokeOnMainThreadAsync(() =>
Expand Down
50 changes: 50 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue32723.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 32723, "Inconsistent appearance of the Title property in Picker control on Windows", PlatformAffected.UWP)]
public class Issue32723 : ContentPage
{
public Issue32723()
{
var picker = new Picker
{
Title = "Select Option",
TitleColor = Colors.Red,
CharacterSpacing = 8,
AutomationId = "issue32723Picker",
WidthRequest = 300,
HeightRequest = 48,
HorizontalOptions = LayoutOptions.Center,
ItemsSource = new List<string> { "Item 1", "Item 2", "Item 3" }
};

var button = new Button
{
Text = "Change Title",
AutomationId = "issue32723Button",
HorizontalOptions = LayoutOptions.Center
};

button.Clicked += (s, e) =>
{
picker.Title = picker.Title == "Select Option" ? "Updated Title" : "Select Option";
picker.TitleColor = picker.TitleColor == Colors.Red ? Colors.Blue : Colors.Red;
};

Content = new VerticalStackLayout
{
Padding = new Thickness(20),
Spacing = 20,
Children =
{
new Label
{
Text = "Test passes if Picker Title displays as placeholder text inside the control.",
AutomationId = "issue32723Label",
HorizontalTextAlignment = TextAlignment.Center
},
picker,
button
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#if WINDOWS
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue32723 : _IssuesUITest
{
public Issue32723(TestDevice device)
: base(device)
{
}

public override string Issue => "Inconsistent appearance of the Title property in Picker control on Windows";

[Test]
[Category(UITestCategories.Picker)]
public void Issue32723PickerTitleDisplaysAsPlaceholder()
{
App.WaitForElement("issue32723Picker");
VerifyScreenshot();
Comment thread
mhrastegari marked this conversation as resolved.
Resolved
}

[Test]
[Category(UITestCategories.Picker)]
public void Issue32723PickerTitleUpdatesAtRuntime()
{
App.WaitForElement("issue32723Button");
App.Tap("issue32723Button");

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.

[moderate] Regression Prevention and Test Coverage — This tap mutates persistent page state and nothing restores it between tests. The host page handler toggles both properties (Issue32723.cs: picker.Title = picker.Title == "Select Option" ? "Updated Title" : "Select Option" and the same for TitleColor), but this fixture does not override ResetAfterEachTest, which defaults to false (src/TestUtils/src/UITest.NUnit/UITestBase.cs:12), and _IssuesUITest.TryToResetTestState() re-navigates only from FixtureSetup/OneTimeSetUp — not per test.

Concrete failure: the two tests carry no [Order], and NUnit does not guarantee method execution order within a fixture. If Issue32723PickerTitleUpdatesAtRuntime runs before Issue32723PickerTitleDisplaysAsPlaceholder, the latter captures the toggled state (Updated Title in blue) and fails against Issue32723PickerTitleDisplaysAsPlaceholder.png. Because the button is a toggle rather than an absolute setter, re-entering this test in the same app session also flips the picker back to the initial state and breaks Issue32723PickerTitleUpdatesAtRuntime.png.

Add protected override bool ResetAfterEachTest => true; (the established convention for state-mutating issue fixtures, e.g. Issue28416.cs:15, Issue20834.cs:14), and/or make the button assign an absolute Title/TitleColor instead of toggling.

App.WaitForElement("issue32723Picker");
VerifyScreenshot();
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Picker/PickerHandler.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static void MapTitle(IPickerHandler handler, IPicker picker)

public static void MapTitleColor(IPickerHandler handler, IPicker picker)
{
handler.PlatformView?.UpdateTitle(picker);
handler.PlatformView?.UpdateTitleColor(picker);
}

public static void MapBackground(IPickerHandler handler, IPicker picker)
Expand Down
Loading
Loading