diff options
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen/Native/ObservableCollection.cs')
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Native/ObservableCollection.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Native/ObservableCollection.cs b/Xamarin.Forms.Platform.Tizen/Native/ObservableCollection.cs new file mode 100644 index 00000000..d33407c9 --- /dev/null +++ b/Xamarin.Forms.Platform.Tizen/Native/ObservableCollection.cs @@ -0,0 +1,30 @@ +using System.Collections.Specialized; +using System.Linq; + +namespace Xamarin.Forms.Platform.Tizen.Native +{ + /// <summary> + /// Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed. + /// </summary> + /// <typeparam name="T">The type of elements in the collection.</typeparam> + internal class ObservableCollection<T> : System.Collections.ObjectModel.ObservableCollection<T> + { + /// <summary> + /// Removes all items from the collection. + /// </summary> + /// <remarks> + /// Fisrt remove all items, send CollectionChanged event with Remove Action + /// Second call ClearItems of base + /// </remarks> + protected override void ClearItems() + { + var oldItems = Items.ToList(); + Items.Clear(); + using (BlockReentrancy()) + { + OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, oldItems)); + } + base.ClearItems(); + } + } +} |