Skip to content

Commit

Permalink
[C] Properly set SelectedItem and Index (#13740) fixes #6571
Browse files Browse the repository at this point in the history
Avoid clearing bindings, by setting the BP instead of the property

fixes #6571
  • Loading branch information
StephaneDelcroix authored Mar 15, 2023
1 parent 762a7fb commit 83fea9c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Controls/src/Core/Picker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,27 +340,27 @@ void UpdateSelectedIndex(object selectedItem)
{
if (ItemsSource != null)
{
SelectedIndex = ItemsSource.IndexOf(selectedItem);
SetValueCore(SelectedIndexProperty, ItemsSource.IndexOf(selectedItem));
return;
}
SelectedIndex = Items.IndexOf(selectedItem);
SetValueCore(SelectedIndexProperty, Items.IndexOf(selectedItem));
}

void UpdateSelectedItem(int index)
{
if (index == -1)
{
SelectedItem = null;
SetValueCore(SelectedItemProperty, null);
return;
}

if (ItemsSource != null)
{
SelectedItem = ItemsSource[index];
SetValueCore(SelectedItemProperty, ItemsSource[index]);
return;
}

SelectedItem = Items[index];
SetValueCore(SelectedItemProperty, Items[index]);
}

/// <inheritdoc/>
Expand Down

0 comments on commit 83fea9c

Please sign in to comment.