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
+25 -13

No files matched your search

@@ -34,20 +34,31 @@ namespace HandyControl.Controls
protected override void OnItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (ItemsHost == null) return;
if (e.OldItems != null)
switch (e.Action)
{
foreach (FrameworkElement item in e.OldItems)
{
ItemsHost.Children.Remove(item);
}
}
if (e.NewItems != null)
{
if (e.NewItems[0] is FrameworkElement item)
{
item.Style = ItemContainerStyle;
ItemsHost.Children.Insert(e.NewStartingIndex, item);
}
case NotifyCollectionChangedAction.Add:
if (e.NewItems != null)
{
if (e.NewItems[0] is FrameworkElement item)
{
item.Style = ItemContainerStyle;
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())
{
AnimationThread?.Abort();
AnimationThread = null;
}
}