本文整理汇总了C#中ObservableCollection.RemoveAll方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.RemoveAll方法的具体用法?C# ObservableCollection.RemoveAll怎么用?C# ObservableCollection.RemoveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.RemoveAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FilterPackagesToKnownRepos
private static void FilterPackagesToKnownRepos(ObservableCollection<PackageViewModel> packages)
{
IEnvironment environment = GetEnvironment();
List<string> repoNames = environment.RemoteRepositories.Select(repo => repo.Name).ToList();
packages.RemoveAll(pack => !repoNames.Contains(pack.Source));
}
示例2: ShouldRemoveAllFromCollection
public void ShouldRemoveAllFromCollection()
{
var collection = new ObservableCollection<int> { 1, 2, 3, 4, 5, 6 };
collection.Count.ShouldBe(6);
collection.RemoveAll();
collection.Count.ShouldBe(0);
collection = new ObservableCollection<int>();
collection.RemoveAll();
}
示例3: ShouldRemoveAll
public void ShouldRemoveAll()
{
var collectionA = new ObservableCollection<Model>();
var wrapper = new ObservableCollectionWrapper<Model, ModelWrapper>(collectionA, item => new ModelWrapper(item));
collectionA.Add(new Model());
collectionA.Add(new Model());
collectionA.Add(new Model());
wrapper.Count.ShouldBe(3);
collectionA.RemoveAll();
wrapper.Count.ShouldBe(0);
}