From 1e6155fea377fe88ca07acef1eb8a8995992575b Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 30 Sep 2021 13:15:17 +0200 Subject: [PATCH] Simplify code a bit. --- src/Avalonia.Controls/ItemsSourceView.cs | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/Avalonia.Controls/ItemsSourceView.cs b/src/Avalonia.Controls/ItemsSourceView.cs index ca95b7acc8..c2d20495ef 100644 --- a/src/Avalonia.Controls/ItemsSourceView.cs +++ b/src/Avalonia.Controls/ItemsSourceView.cs @@ -94,15 +94,9 @@ namespace Avalonia.Controls { add { - if (_inner is null) - ThrowDisposed(); - - if (_collectionChanged is null) + if (_collectionChanged is null && Inner is INotifyCollectionChanged incc) { - if (_inner is INotifyCollectionChanged incc) - { - incc.CollectionChanged += OnCollectionChanged; - } + incc.CollectionChanged += OnCollectionChanged; } _collectionChanged += value; @@ -110,17 +104,11 @@ namespace Avalonia.Controls remove { - if (_inner is null) - ThrowDisposed(); - _collectionChanged -= value; - if (_collectionChanged is null) + if (_collectionChanged is null && Inner is INotifyCollectionChanged incc) { - if (_inner is INotifyCollectionChanged incc) - { - incc.CollectionChanged -= OnCollectionChanged; - } + incc.CollectionChanged -= OnCollectionChanged; } } }