Skip to content

Commit

Permalink
fix(iOS): ListView delete item with Bindings
Browse files Browse the repository at this point in the history
(cherry picked from commit 2fa709a)
  • Loading branch information
ajpinedam authored and mergify[bot] committed Jul 21, 2023
1 parent e044464 commit eccdb9b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Uno.UI/UI/Xaml/Controls/ItemsControl/ItemsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,14 @@ public bool IsGrouping
new FrameworkPropertyMetadata(DependencyProperty.UnsetValue)
);

internal static DependencyProperty ItemHasManualBindingExpressionProperty { get; } =
DependencyProperty.RegisterAttached(
"ItemHasManualBindingExpression",
typeof(bool),
typeof(ItemsControl),
new FrameworkPropertyMetadata(false)
);

#endregion

internal bool AreEmptyGroupsHidden => CollectionGroups != null && (GroupStyle.FirstOrDefault()?.HidesIfEmpty ?? false);
Expand Down Expand Up @@ -1178,7 +1186,7 @@ static void ClearPropertyWhenNoExpression(ContentControl target, DependencyPrope
// We must not clear the properties of the container if a binding expression
// is defined. This is a use-case present for TreeView, which generally uses TreeViewItem
// at the root of hierarchical templates.
if (target.GetBindingExpression(property) is null)
if (target.GetBindingExpression(property) is null || (bool)target.GetValue(ItemHasManualBindingExpressionProperty) == true)
{
target.ClearValue(property);
}
Expand Down Expand Up @@ -1253,6 +1261,8 @@ void SetContent(UIElement container, DependencyProperty contentProperty)
Path = displayMemberPath,
Source = item
});

container.SetValue(ItemHasManualBindingExpressionProperty, true);
}
}

Expand Down Expand Up @@ -1291,6 +1301,7 @@ void SetContent(UIElement container, DependencyProperty contentProperty)
if (!containerAsContentControl.IsContainerFromTemplateRoot && containerAsContentControl.GetBindingExpression(ContentControl.ContentProperty) == null)
{
containerAsContentControl.SetBinding(ContentControl.ContentProperty, new Binding());
containerAsContentControl.SetValue(ItemHasManualBindingExpressionProperty, true);
}
}
}
Expand Down

0 comments on commit eccdb9b

Please sign in to comment.