add ignoreTextChanged

This commit is contained in:
NaBian committed 2021-09-08 00:08:56 +08:00
1 parent fbaeb194e8
commit eea87ad879
34 files changed
+733 -6

No files matched your search

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
@@ -41,6 +42,19 @@ namespace HandyControl.Collections
}
}
public ManualObservableCollection()
{
}
public ManualObservableCollection(List<T> list) : base(list != null ? new List<T>(list.Count) : list) => CopyFrom(list);
public ManualObservableCollection(IEnumerable<T> collection)
{
if (collection == null) throw new ArgumentNullException(nameof(collection));
CopyFrom(collection);
}
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
{
if (!CanNotify) return;
@@ -54,5 +68,18 @@ namespace HandyControl.Collections
base.OnCollectionChanged(e);
}
private void CopyFrom(IEnumerable<T> collection)
{
var items = Items;
if (collection != null)
{
using var enumerator = collection.GetEnumerator();
while (enumerator.MoveNext())
{
items.Add(enumerator.Current);
}
}
}
}
}