minor fix

This commit is contained in:
NaBian committed 2020-07-22 22:45:00 +08:00
1 parent c3ba2d5c96
commit f45aa5471c
2 files changed
+18 -6

No files matched your search

@@ -34,13 +34,10 @@ namespace HandyControl.Controls
protected override void OnItemsChanged(object sender, NotifyCollectionChangedEventArgs e) protected override void OnItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
{ {
if (ItemsHost == null) return; if (ItemsHost == null) return;
if (e.OldItems != null)
switch (e.Action)
{ {
foreach (FrameworkElement item in e.OldItems) case NotifyCollectionChangedAction.Add:
{
ItemsHost.Children.Remove(item);
}
}
if (e.NewItems != null) if (e.NewItems != null)
{ {
if (e.NewItems[0] is FrameworkElement item) if (e.NewItems[0] is FrameworkElement item)
@@ -49,6 +46,20 @@ namespace HandyControl.Controls
ItemsHost.Children.Insert(e.NewStartingIndex, item); ItemsHost.Children.Insert(e.NewStartingIndex, item);
} }
} }
break;
case NotifyCollectionChangedAction.Remove:
if (e.OldItems != null)
{
foreach (FrameworkElement item in e.OldItems)
{
ItemsHost.Children.Remove(item);
}
}
break;
case NotifyCollectionChangedAction.Reset:
ItemsHost.Children.Clear();
break;
}
} }
} }
} }
@@ -175,6 +175,7 @@ namespace HandyControl.Tools
if (!ImageInfoList.Any()) if (!ImageInfoList.Any())
{ {
AnimationThread?.Abort();
AnimationThread = null; AnimationThread = null;
} }
} }