/// <summary> /// Adds a tree view item /// </summary> /// <param name="parent">Parent of the item</param> /// <param name="item">The item to be added</param> private void Add(DisplayableTreeViewItem parent, DisplayableTreeViewItem item) { ObservableCollection <DisplayableTreeViewItem> siblings; if (parent == null) { siblings = ItemSource; } else { siblings = parent.Items; parent.IsExpanded = true; } int index = FindIndex(siblings, item); if (index == -1) { index = 0; } if (parent == null) { ItemSource.Insert(index, item); } else { parent.Items.Insert(index, item); } CheckVisibility(); }
public void AddTab(TabItem tab, int position = 0, bool selectNewPosition = false) { if (selectNewPosition) { _position = position; } ItemSource.Insert(position, tab); }
/// <summary> /// Invoked internally to add a new object at a specific /// </summary> /// <param name="index">The index in which the item will be added.</param> /// <param name="obj">The object to insert at the index.</param> protected virtual void Add(int index, T obj) { ItemSource.Insert(index, obj); if (!(ItemSource is INotifyCollectionChanged)) { HandleCollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, obj, index)); } }
public override void Copy() { if (CanCopy == false) { return; } var index = ItemSource.IndexOf(this); ItemSource.Insert(index, Clone() as PhaseItemViewModel); }
public override void Copy() { if (CanCopy == false) { return; } var index = (Parent as SetCardItemViewModel).Items.IndexOf(this); ItemSource.Insert(index, Clone() as SetCardAltItemViewModel); }
/// <summary> /// Sort the tree view item source collection /// </summary> private void Sort() { List <DisplayableTreeViewItem> items = ItemSource.ToList <DisplayableTreeViewItem>(); items.Sort((x, y) => CompareItems(x, y)); ItemSource.Clear(); for (int i = 0; i < items.Count; i++) { ItemSource.Insert(i, Sort(items[i])); } }
public override void Insert() { if (CanInsert == false) { return; } var index = ItemSource.IndexOf(this); ItemSource.Insert(index, new PhaseItemViewModel() { Parent = Parent, ItemSource = ItemSource }); }
public override void Insert() { if (CanInsert == false) { return; } var index = ItemSource.IndexOf(this); ItemSource.Insert(index, new SetPackageItemViewModel() { ItemSource = ItemSource, Parent = Parent }); }
public override void Insert() { if (CanInsert == false) { return; } var index = (Parent as SetCardItemViewModel).Items.IndexOf(this); ItemSource.Insert(index, new SetCardAltItemViewModel() { ItemSource = ItemSource, Parent = Parent, Name = "Alt" }); }
public override void Insert() { if (CanInsert == false) { return; } var index = ItemSource.IndexOf(this); ItemSource.Insert(index, new PropertyItemViewModel() { Parent = Parent, ItemSource = ItemSource, Name = "Property" }); base.Insert(); }
public override void Insert() { if (CanInsert == false) { return; } var index = ItemSource.IndexOf(this); ItemSource.Insert(index, new BoardItemViewModel() { ItemSource = ItemSource, Parent = Parent, Name = Utils.GetUniqueName("New Board", ItemSource.Select(x => (x as BoardItemViewModel).Name)) }); }