コード例 #1
0
        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();
                }
            }
        }