/// <summary> /// Converts the BreadCrumbItems /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void OnBreadcrumbConvertItem(object sender, BreadcrumbConvertItemEventArgs e) { if (_isloaded) { if (breadcrumb.SelectedItem is BreadCrumbViewModel) { SelectedItems.Insert(0, breadcrumb.SelectedItem); return; } ConvertItemHelper.ItemTitle = ((WorkspaceItem)(breadcrumb.SelectedItem)).ItemTitle; e.Path = ConvertItemHelper.ItemTitle; return; } if (Vm.Treeviewitem != null) { if ((Vm.Treeviewitem.Header is WorkspaceItem) && (Vm.Treeviewitem.Header as WorkspaceItem).ItemImage.Length == 0) { (Vm.Treeviewitem.Header as WorkspaceItem).ItemImage = GetLocalItemImageForBreadCrumb(); } ConvertItemHelper.Treeviewitem = Vm.Treeviewitem; // ConvertItemHelper.HandleConvertItem(sender, e); } UpdateSelectedItems(); ConvertItemHelper.GetTrail(breadcrumb.RootItem, breadcrumb.SelectedItem); ConvertItemHelper.HandleConvertItem(sender, e); #region "need to check" //Loads dynamically the child item for the selected breadcrumb menu item //if (e.Item.GetType().Name == Constants.WorkspaceItem) //{ // if (((WorkspaceItem)e.Item).Children != null) // { // foreach (var item in ((WorkspaceItem)e.Item).Children) // { // if (item.Children != null) // foreach (var childitem in item.Children) // { // if (childitem.Children == null || childitem.Children.Length == 0) // { // ChildItem.Add(childitem); // //Vm.EventBroker.RaiseGetChild(new LoadWorkspaceItemEventArgs // //{ // // WorkspaceId = childitem.Id, // // ItemId = childitem.ItemId // //}); // } // } // } // ConvertItemHelper.ChildItem = ChildItem; // } // } #endregion }
private void ChipItem_SelectedChip(object sender, RoutedEventArgs e) { var item = sender as WKChipSearch; CustomEventArgs customEventArgs = e as CustomEventArgs; if (customEventArgs.IsEditableItem) { SelectedItemsEditable.Add(e.OriginalSource); } SelectedItems.Insert(SelectedItems.Count != 0 ? SelectedItems.Count - 1 : 0, e.OriginalSource); }
protected override void InsertItem(int index, ObjectT item) { item.SelectedChanged += item_SelectedChanged; base.InsertItem(index, item); if (item.Selected) { int newIndex = Enumerable.Range(0, index).Where(i => this[i].Selected).Count(); SelectedItems.Insert(newIndex, item); } else { int newIndex = Enumerable.Range(0, index).Where(i => !this[i].Selected).Count(); UnselectedItems.Insert(newIndex, item); } }
private void UpdateSelectedItems() { var updateSelectedItems = new DeferrableObservableCollection <object>(); if (null != breadcrumb.SelectedItem) { SelectedItems.BeginUpdate(); try { if (!(breadcrumb.SelectedItem is BreadCrumbViewModel)) { if (((WorkspaceItem)(breadcrumb.SelectedItem)).ItemId == "ROOT") { SelectedItems.Clear(); SelectedItems.Insert(0, breadcrumb.SelectedItem); return; } SelectedItems.Insert(SelectedItems.Count, breadcrumb.SelectedItem); if (SelectedItems.Count <= 1) { ConvertItemHelper.SelectedItems = SelectedItems; return; } foreach (var workspaceItem in SelectedItems) { updateSelectedItems.Insert(updateSelectedItems.Count, workspaceItem); if (workspaceItem == breadcrumb.SelectedItem) { ConvertItemHelper.SelectedItems = updateSelectedItems; break; } } SelectedItems.Clear(); SelectedItems = updateSelectedItems; ConvertItemHelper.SelectedItems = updateSelectedItems; } else { SelectedItems.Clear(); SelectedItems.Insert(0, breadcrumb.SelectedItem); return; } #region unusedcode //for (int i = 0; i < SelectedItems.Count-2; i++) //{ // SelectedItems.RemoveAt(i);//} //ConvertItemHelper.TreeViewItemPath = null; //for (int i = 0; i < SelectedItems.Count; i++) //{ // if (SelectedItems[i] is BreadCrumbViewModel) // { // ConvertItemHelper.TreeViewItemPath = "ROOT"; // } // else // { // var itemTitle = ((WorkspaceItem)SelectedItems[i]).ItemTitle; // ConvertItemHelper.TreeViewItemPath = string.Format("{0} / {1}", // ConvertItemHelper.TreeViewItemPath, // itemTitle); // } //} #endregion } finally { SelectedItems.EndUpdate(); } } }
void IList <Security> .Insert(int index, Security item) { SelectedItems.Insert(index, GetItem(item)); }