Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectableCollectionSelector{T}"/> class.
 /// </summary>
 /// <param name="items">The source items. This instance is the only way to modify the selector's collection.</param>
 public SelectableCollectionSelector(ObservableCollection <T> items) : base(items)
 {
     foreach (var selectableItem in Items)
     {
         SelectionChangedEventManager.AddListener(selectableItem, this);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Called when items are added to the source collection.
 /// </summary>
 /// <param name="newStartingIndex">New index of the starting.</param>
 /// <param name="newItems">The new items.</param>
 protected override void OnItemsAdded(int newStartingIndex, IList newItems)
 {
     base.OnItemsAdded(newStartingIndex, newItems);
     foreach (T selectableItem in newItems)
     {
         SelectionChangedEventManager.AddListener(selectableItem, this);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Called when the source collection is reseted.
 /// </summary>
 protected override void OnCollectionReset()
 {
     base.OnCollectionReset();
     foreach (var selectableItem in Items)
     {
         SelectionChangedEventManager.AddListener(selectableItem, this);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Called when items are replaced in the source collection.
 /// </summary>
 /// <param name="oldStartingIndex">Old index of the starting.</param>
 /// <param name="oldItems">The old items.</param>
 /// <param name="newStartingIndex">New index of the starting.</param>
 /// <param name="newItems">The new items.</param>
 protected override void OnItemsReplaced(int oldStartingIndex, IList oldItems, int newStartingIndex, IList newItems)
 {
     foreach (T selectableItem in oldItems)
     {
         SelectionChangedEventManager.RemoveListener(selectableItem, this);
     }
     base.OnItemsReplaced(oldStartingIndex, oldItems, newStartingIndex, newItems);
     foreach (T selectableItem in newItems)
     {
         SelectionChangedEventManager.AddListener(selectableItem, this);
     }
 }