/// <summary> /// Notifies this tree view model that the selection state of an item which is part of it's logical descendants has changed. /// </summary> /// <param name="item"></param> public void NotifyItemSelectionChanged(ITreeViewModelItem item) { if (!HasBoundSelection) { SetDefaultSelectionBinding(); } SelectionBinding.OnItemSelectionStatusChanged(item); }
/// <summary> /// Handles the item selection changed event for all the current items. /// Initializes a default selection binding in accordance with the current selection mode if there is none and forwards the selected item to it. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ItemSelectionChanged(object sender, PropertyChangedEventArgs e) { if (!HasBoundSelection) { SetDefaultSelectionBinding(); } SelectionBinding.OnItemSelectionStatusChanged((IListViewModelItem)sender); }
/// <summary> /// Breaks the current selection binding. <para/> /// NOTE : If there is no active selection binding, an exception will be thrown. /// </summary> protected void BreakSelectionBinding() { if (!HasBoundSelection) { throw new Exception("Error : Attempting to break a selection binding on a list view model that is not bound to any selection."); } SelectionBinding.TearDown(); SelectionBinding = null; }
/// <summary> /// Invalidates the children of this list view model internally, without updating the UI. /// </summary> private void InvalidateChildrenInternal() { if (!HasBoundSelection) { SetDefaultSelectionBinding(); } foreach (var item in Items) { PropertyChangedEventManager.RemoveHandler(item, ItemSelectionChanged, nameof(item.IsSelected)); item.TearDown(); SelectionBinding.OnItemDisposed(item); } items.Clear(); foreach (var item in CreateContentItems()) { item.Initialize(this); PropertyChangedEventManager.AddHandler(item, ItemSelectionChanged, nameof(item.IsSelected)); SelectionBinding.OnItemCreated(item); items.Add(item); } }
/// <summary> /// Notifies this tree view model that an item has been removed from it's logical descendants. /// </summary> /// <param name="item"></param> public void NotifyItemDisposed(ITreeViewModelItem item) { SelectionBinding.OnItemDisposed(item); items.Remove(item); }
/******************************************************* ***************** Item Notifications ****************** *******************************************************/ /// <summary> /// Notifies this tree view model that a new item has been created as part of it's logical descendants. /// </summary> /// <param name="item"></param> public void NotifyItemCreated(ITreeViewModelItem item) { SelectionBinding.OnItemCreated(item); items.Add(item); }