From 8b6a5d37311ad696a9624c7ed38b1abf59c9057c Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Tue, 24 Sep 2024 18:57:10 +0200 Subject: [PATCH] feat: Allow selecting custom values on Selector --- src/Uno.UI/UI/Xaml/Controls/Primitives/Selector.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/Controls/Primitives/Selector.cs b/src/Uno.UI/UI/Xaml/Controls/Primitives/Selector.cs index 44a20c6cb416..b58c7cfd457f 100644 --- a/src/Uno.UI/UI/Xaml/Controls/Primitives/Selector.cs +++ b/src/Uno.UI/UI/Xaml/Controls/Primitives/Selector.cs @@ -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) { @@ -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