Skip to content

Instantly share code, notes, and snippets.

@atzimler
Created February 28, 2019 23:59
Show Gist options
  • Save atzimler/cfc8ab3271bb4f7e3c7e44a61e6c8041 to your computer and use it in GitHub Desktop.
Save atzimler/cfc8ab3271bb4f7e3c7e44a61e6c8041 to your computer and use it in GitHub Desktop.
ObservableCollection Example 1
public void ItemsToBeAddedAreRejectedCorrectly()
{
var observableCollection = new ObservableCollection<int>();
observableCollection.CollectionChanged += (o, e) =>
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
observableCollection.Clear();
}
};
observableCollection.Add(13);
observableCollection.Count.Should().Be(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment