fix: Prevent duplicate items in MultiComboBox SelectedItems by adding existence check
This commit is contained in:
@@ -52,8 +52,13 @@ public class MultiComboBoxItem: ContentControl
|
||||
{
|
||||
base.OnAttachedToLogicalTree(e);
|
||||
_parent = this.FindLogicalAncestorOfType<MultiComboBox>();
|
||||
if(this.IsSelected)
|
||||
_parent?.SelectedItems?.Add(this.DataContext);
|
||||
if (this.IsSelected &&
|
||||
_parent is not null &&
|
||||
_parent.SelectedItems is not null &&
|
||||
!_parent.SelectedItems.Contains(this.DataContext))
|
||||
{
|
||||
_parent.SelectedItems.Add(this.DataContext);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user