Skip to content

Commit

Permalink
fix alternate alyout not updating on in some cases (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
huynhsontung authored Jan 28, 2024
1 parent 609270b commit 18e4801
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Screenbox/Controls/Interactions/AlternatingListViewBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,20 @@ protected override void OnAttached()

AssociatedObject.ActualThemeChanged += OnActualThemeChanged;
AssociatedObject.ContainerContentChanging += OnContainerContentChanging;
if (AssociatedObject.Items != null)
if (AssociatedObject.Items == null) return;
AssociatedObject.Items.VectorChanged += ItemsOnVectorChanged;
if (AssociatedObject.Items.Count > 0)
{
AssociatedObject.Items.VectorChanged += ItemsOnVectorChanged;
// Update alternate layout on attached if there are items.
// Item containers may be cached if the list is previously loaded
// and ContainerContentChanging event is not triggered.
for (int i = 0; i < AssociatedObject.Items.Count; i++)
{
if (AssociatedObject.ContainerFromIndex(i) is SelectorItem itemContainer)
{
UpdateAlternateLayout(itemContainer, i);
}
}
}
}

Expand Down

0 comments on commit 18e4801

Please sign in to comment.