@@ -31,28 +31,28 @@ public static partial class ListViewExtensions
3131 /// </summary>
3232 /// <param name="obj">The <see cref="ListViewBase"/> to get the associated <see cref="Brush"/> from</param>
3333 /// <returns>The <see cref="Brush"/> associated with the <see cref="ListViewBase"/></returns>
34- public static Brush GetAlternateColor ( ListViewBase obj ) => ( Brush ) obj . GetValue ( AlternateColorProperty ) ;
34+ public static Brush ? GetAlternateColor ( ListViewBase obj ) => ( Brush ? ) obj . GetValue ( AlternateColorProperty ) ;
3535
3636 /// <summary>
3737 /// Sets the alternate <see cref="Brush"/> associated with the specified <see cref="DependencyObject"/>
3838 /// </summary>
3939 /// <param name="obj">The <see cref="ListViewBase"/> to associate the <see cref="Brush"/> with</param>
4040 /// <param name="value">The <see cref="Brush"/> for binding to the <see cref="ListViewBase"/></param>
41- public static void SetAlternateColor ( ListViewBase obj , Brush value ) => obj . SetValue ( AlternateColorProperty , value ) ;
41+ public static void SetAlternateColor ( ListViewBase obj , Brush ? value ) => obj . SetValue ( AlternateColorProperty , value ) ;
4242
4343 /// <summary>
4444 /// Gets the <see cref="DataTemplate"/> associated with the specified <see cref="ListViewBase"/>
4545 /// </summary>
4646 /// <param name="obj">The <see cref="ListViewBase"/> to get the associated <see cref="DataTemplate"/> from</param>
4747 /// <returns>The <see cref="DataTemplate"/> associated with the <see cref="ListViewBase"/></returns>
48- public static DataTemplate GetAlternateItemTemplate ( ListViewBase obj ) => ( DataTemplate ) obj . GetValue ( AlternateItemTemplateProperty ) ;
48+ public static DataTemplate ? GetAlternateItemTemplate ( ListViewBase obj ) => ( DataTemplate ? ) obj . GetValue ( AlternateItemTemplateProperty ) ;
4949
5050 /// <summary>
5151 /// Sets the <see cref="DataTemplate"/> associated with the specified <see cref="ListViewBase"/>
5252 /// </summary>
5353 /// <param name="obj">The <see cref="ListViewBase"/> to associate the <see cref="DataTemplate"/> with</param>
5454 /// <param name="value">The <see cref="DataTemplate"/> for binding to the <see cref="ListViewBase"/></param>
55- public static void SetAlternateItemTemplate ( ListViewBase obj , DataTemplate value ) => obj . SetValue ( AlternateItemTemplateProperty , value ) ;
55+ public static void SetAlternateItemTemplate ( ListViewBase obj , DataTemplate ? value ) => obj . SetValue ( AlternateItemTemplateProperty , value ) ;
5656
5757 private static void OnAlternateColorPropertyChanged ( DependencyObject sender , DependencyPropertyChangedEventArgs args )
5858 {
@@ -64,14 +64,18 @@ private static void OnAlternateColorPropertyChanged(DependencyObject sender, Dep
6464 listViewBase . Items . VectorChanged -= ColorItemsVectorChanged ;
6565 listViewBase . Unloaded -= OnListViewBaseUnloaded_AltRow ;
6666
67- _trackedListViews [ listViewBase . Items ] = listViewBase ;
68-
6967 // Resubscribe to events as necessary
7068 if ( GetAlternateColor ( listViewBase ) is not null )
7169 {
7270 listViewBase . ContainerContentChanging += ColorContainerContentChanging ;
7371 listViewBase . Items . VectorChanged += ColorItemsVectorChanged ;
7472 listViewBase . Unloaded += OnListViewBaseUnloaded_AltRow ;
73+
74+ _trackedListViews [ listViewBase . Items ] = listViewBase ;
75+ }
76+ else
77+ {
78+ _trackedListViews . Remove ( listViewBase . Items ) ;
7579 }
7680 }
7781
0 commit comments