Skip to content

Commit 480cd6c

Browse files
committed
Merge
2 parents f8e5091 + 98e14cb commit 480cd6c

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

components/Extensions/src/ListViewBase/ListViewExtensions.AlternateRows.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ private static void OnAlternateRowPropertyChanged(DependencyObject sender, Depen
8585
listViewBase.Items.VectorChanged -= OnItemsVectorChanged;
8686
listViewBase.Unloaded -= OnListViewBaseUnloaded_AltRow;
8787

88-
_trackedListViews[listViewBase.Items] = listViewBase;
89-
9088
// Resubscribe to events as necessary
9189
var altColor = GetAlternateColor(listViewBase);
9290
var altStyle = GetAlternateStyle(listViewBase);
@@ -98,10 +96,16 @@ private static void OnAlternateRowPropertyChanged(DependencyObject sender, Depen
9896
listViewBase.ContainerContentChanging += OnContainerContentChanging;
9997
listViewBase.Items.VectorChanged += OnItemsVectorChanged;
10098
listViewBase.Unloaded += OnListViewBaseUnloaded_AltRow;
99+
100+
_trackedListViews[listViewBase.Items] = listViewBase;
101+
}
102+
else
103+
{
104+
_trackedListViews.Remove(listViewBase.Items);
101105
}
102106

103-
// Update all items to apply the new property
104-
UpdateItems(listViewBase);
107+
// Update all items to apply the new property
108+
UpdateItems(listViewBase);
105109
}
106110

107111
private static void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) => UpdateItem(sender, args.ItemIndex);

components/Extensions/src/ListViewBase/ListViewExtensions.StretchItemContainer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static partial class ListViewExtensions
2020
/// <param name="obj">The <see cref="ListViewBase"/> to get the associated <see cref="ItemContainerStretchDirection"/> from</param>
2121
/// <returns>The <see cref="ItemContainerStretchDirection"/> associated with the <see cref="ListViewBase"/></returns>
2222
public static ItemContainerStretchDirection? GetItemContainerStretchDirection(ListViewBase obj)
23-
=> (ItemContainerStretchDirection)obj.GetValue(ItemContainerStretchDirectionProperty);
23+
=> (ItemContainerStretchDirection?)obj.GetValue(ItemContainerStretchDirectionProperty);
2424

2525
/// <summary>
2626
/// Sets the stretch <see cref="ItemContainerStretchDirection"/> associated with the specified <see cref="ListViewBase"/>
@@ -51,11 +51,11 @@ private static void ItemContainerStretchDirectionChanging(ListViewBase sender, C
5151
{
5252
var stretchDirection = GetItemContainerStretchDirection(sender);
5353

54-
// Set vertical content stretching
54+
// Set horizontal content stretching
5555
if (stretchDirection is ItemContainerStretchDirection.Horizontal or ItemContainerStretchDirection.Both)
5656
args.ItemContainer.HorizontalContentAlignment = HorizontalAlignment.Stretch;
5757

58-
// Set horizontal content stretching
58+
// Set vertical content stretching
5959
if (stretchDirection is ItemContainerStretchDirection.Vertical or ItemContainerStretchDirection.Both)
6060
args.ItemContainer.VerticalContentAlignment = VerticalAlignment.Stretch;
6161
}

0 commit comments

Comments
 (0)