Skip to content

Commit

Permalink
feat: Allow selecting custom values on Selector
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Oct 5, 2024
1 parent 69a7287 commit 8b6a5d3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Uno.UI/UI/Xaml/Controls/Primitives/Selector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ internal virtual void OnSelectedItemChanged(object oldSelectedItem, object selec
var wasSelectionUnset = oldSelectedItem == null && (!GetItems()?.Contains(null) ?? false);
var isSelectionUnset = false;
var items = GetItems();
if (!items?.Contains(selectedItem) ?? false)
if ((!items?.Contains(selectedItem) ?? false) && !AreCustomValuesAllowed())
{
if (selectedItem == null)
{
Expand Down Expand Up @@ -415,7 +415,7 @@ private static object SelectedValueCoerce(DependencyObject snd, object baseValue
{
return baseValue; // Setting the SelectedValue won't update the index when a _path is used.
}
return selector.GetItems()?.Contains(baseValue) ?? false ? baseValue : null;
return (selector.GetItems()?.Contains(baseValue) ?? false) || selector.AreCustomValuesAllowed() ? baseValue : null;
}

public bool? IsSynchronizedWithCurrentItem
Expand Down

0 comments on commit 8b6a5d3

Please sign in to comment.