From cb3a1f206968b787e69cdae567b420ad5b2309a9 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 23 Jun 2007 17:51:14 +0000 Subject: [PATCH] Support ToolBox and PropertyGrid in WPF designer. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2573 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/SettingsViewContent.cs | 6 + .../Project/Src/Gui/ViewContentControl.cs | 2 - .../StandaloneDesigner/Window1.xaml.cs | 4 + .../WpfDesign.AddIn/Src/WpfSideTabItem.cs | 37 ++++++ .../WpfDesign.AddIn/Src/WpfToolbox.cs | 110 ++++++++++++++++++ .../WpfDesign.AddIn/Src/WpfViewContent.cs | 77 +++++++++++- .../WpfDesign.AddIn/WpfDesign.AddIn.csproj | 7 ++ .../Controls/PropertyEditor/PropertyEditor.cs | 4 +- .../Project/DragDropExceptionHandler.cs | 24 ++++ .../Project/Services/CreateComponentTool.cs | 46 +++++--- .../Project/WpfDesign.Designer.csproj | 1 + .../Gui/Pads/PropertyPad/PropertyContainer.cs | 12 ++ .../Src/Gui/Pads/PropertyPad/PropertyPad.cs | 23 ++++ .../Src/Gui/Workbench/DefaultWorkbench.cs | 1 - .../Project/SideBar/SideBar.cs | 13 ++- 15 files changed, 336 insertions(+), 31 deletions(-) create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfSideTabItem.cs create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfToolbox.cs create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DragDropExceptionHandler.cs diff --git a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewContent.cs b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewContent.cs index a4eec9f0ea..cfc5d8219a 100644 --- a/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewContent.cs +++ b/src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewContent.cs @@ -87,5 +87,11 @@ namespace ICSharpCode.SettingsEditor return propertyContainer; } } + + public override void Dispose() + { + propertyContainer.Clear(); + base.Dispose(); + } } } diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.cs index f95f706084..2978f463ed 100644 --- a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.cs +++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.cs @@ -205,7 +205,5 @@ namespace WorkflowDesigner } } #endregion - - } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Window1.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Window1.xaml.cs index 266a195bed..987e1a3fbe 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Window1.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Window1.xaml.cs @@ -21,6 +21,9 @@ namespace StandaloneDesigner { public Window1() { + DragDropExceptionHandler.HandleException = delegate (Exception ex) { + MessageBox.Show(ex.ToString()); + }; try { InitializeComponent(); foreach (object o in toolBar.Items) { @@ -101,3 +104,4 @@ namespace StandaloneDesigner } } + diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfSideTabItem.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfSideTabItem.cs new file mode 100644 index 0000000000..b0cce31779 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfSideTabItem.cs @@ -0,0 +1,37 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Drawing; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.WpfDesign.Designer.Services; + +namespace ICSharpCode.WpfDesign.AddIn +{ + /// + /// Description of WpfSideTabItem. + /// + public class WpfSideTabItem : SharpDevelopSideTabItem + { + public WpfSideTabItem(Type componentType) : base(componentType.Name, new CreateComponentTool(componentType)) + { + CanBeRenamed = false; +// this.Icon = tag.Bitmap; + } + + ///create a default tabitem : a pointer icon with an empty toolboxitem + public WpfSideTabItem() : base("Pointer") + { + CanBeRenamed = false; + CanBeDeleted = false; + Bitmap pointerBitmap = new Bitmap(IconService.GetBitmap("Icons.16x16.FormsDesigner.PointerIcon"), 16, 16); + this.Icon = pointerBitmap; + this.Tag = null; + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfToolbox.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfToolbox.cs new file mode 100644 index 0000000000..40f68f2b30 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfToolbox.cs @@ -0,0 +1,110 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using System.Windows.Forms; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Widgets.SideBar; +using WPF = System.Windows.Controls; + +namespace ICSharpCode.WpfDesign.AddIn +{ + /// + /// Manages the WpfToolbox. + /// + public class WpfToolbox + { + static WpfToolbox instance; + + public static WpfToolbox Instance { + get { + Debug.Assert(WorkbenchSingleton.InvokeRequired == false); + if (instance == null) { + instance = new WpfToolbox(); + } + return instance; + } + } + + IToolService toolService; + WpfSideBar sideBar; + + public WpfToolbox() + { + sideBar = new WpfSideBar(); + SideTab sideTab = new SideTab(sideBar, "Windows Presentation Foundation"); + sideTab.DisplayName = StringParser.Parse(sideTab.Name); + sideTab.CanBeDeleted = false; + sideTab.ChoosedItemChanged += OnChoosedItemChanged; + + sideTab.Items.Add(new WpfSideTabItem()); + sideTab.Items.Add(new WpfSideTabItem(typeof(WPF.Button))); + sideTab.Items.Add(new WpfSideTabItem(typeof(WPF.CheckBox))); + sideTab.Items.Add(new WpfSideTabItem(typeof(WPF.TextBox))); + sideTab.Items.Add(new WpfSideTabItem(typeof(WPF.Grid))); + sideTab.Items.Add(new WpfSideTabItem(typeof(WPF.Canvas))); + + sideBar.Tabs.Add(sideTab); + sideBar.ActiveTab = sideTab; + } + + void OnChoosedItemChanged(object sender, EventArgs e) + { + if (toolService != null) { + ITool newTool = null; + if (sideBar.ActiveTab != null && sideBar.ActiveTab.ChoosedItem != null) { + newTool = sideBar.ActiveTab.ChoosedItem.Tag as ITool; + } + toolService.CurrentTool = newTool ?? toolService.PointerTool; + } + } + + public Control ToolboxControl { + get { return sideBar; } + } + + public IToolService ToolService { + get { return toolService; } + set { + if (toolService != null) { + toolService.CurrentToolChanged -= OnCurrentToolChanged; + } + toolService = value; + if (toolService != null) { + toolService.CurrentToolChanged += OnCurrentToolChanged; + OnCurrentToolChanged(null, null); + } + } + } + + void OnCurrentToolChanged(object sender, EventArgs e) + { + Debug.WriteLine("WpfToolbox.OnCurrentToolChanged"); +// for (int i = 0; i < this.Items.Count; i++) { +// if (((ListBoxItem)this.Items[i]).Tag == toolService.CurrentTool) { +// this.SelectedIndex = i; +// return; +// } +// } +// this.SelectedIndex = -1; + } + + sealed class WpfSideBar : SharpDevelopSideBar + { + protected override object StartItemDrag(SideTabItem draggedItem) + { + if (this.ActiveTab.ChoosedItem != draggedItem && this.ActiveTab.Items.Contains(draggedItem)) { + this.ActiveTab.ChoosedItem = draggedItem; + } + return new System.Windows.DataObject(draggedItem.Tag); + } + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs index 0ad379f100..53234c1fbb 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs @@ -6,39 +6,46 @@ // using System; +using System.Collections.Generic; using System.Text; +using System.Windows.Forms; +using System.Windows.Forms.Integration; using System.Xml; + using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Gui; -using System.Windows.Forms; -using System.Windows.Forms.Integration; using ICSharpCode.WpfDesign.Designer; +using ICSharpCode.WpfDesign.PropertyEditor; namespace ICSharpCode.WpfDesign.AddIn { /// /// Description of WpfViewContent. /// - public class WpfViewContent : AbstractViewContentHandlingLoadErrors + public class WpfViewContent : AbstractViewContentHandlingLoadErrors, IHasPropertyContainer, IToolsHost { ElementHost wpfHost; DesignSurface designer; public WpfViewContent(OpenedFile file) : base(file) { + this.TabPageText = "${res:FormsDesigner.DesignTabPages.DesignTabPage}"; } protected override void LoadInternal(OpenedFile file, System.IO.Stream stream) { if (designer == null) { // initialize designer on first load + DragDropExceptionHandler.HandleException = ICSharpCode.Core.MessageService.ShowError; wpfHost = new ElementHost(); designer = new DesignSurface(); wpfHost.Child = designer; this.UserControl = wpfHost; + InitPropertyEditor(); } using (XmlTextReader r = new XmlTextReader(stream)) { designer.LoadDesigner(r); + designer.DesignContext.Services.Selection.SelectionChanged += OnSelectionChanged; } } @@ -49,5 +56,69 @@ namespace ICSharpCode.WpfDesign.AddIn designer.SaveDesigner(xmlWriter); } } + + #region Property editor / SelectionChanged + Designer.PropertyEditor propertyEditor; + ElementHost propertyEditorHost; + + void InitPropertyEditor() + { + propertyEditorHost = new ElementHost(); + propertyEditor = new Designer.PropertyEditor(); + propertyEditorHost.Child = propertyEditor; + propertyContainer.PropertyGridReplacementControl = propertyEditorHost; + } + + ICollection oldItems = new DesignItem[0]; + + void OnSelectionChanged(object sender, DesignItemCollectionEventArgs e) + { + ISelectionService selectionService = designer.DesignContext.Services.Selection; + ICollection items = selectionService.SelectedItems; + if (!IsCollectionWithSameElements(items, oldItems)) { + IPropertyEditorDataSource dataSource = DesignItemDataSource.GetDataSourceForDesignItems(items); + propertyEditor.EditedObject = dataSource; + oldItems = items; + } + } + + static bool IsCollectionWithSameElements(ICollection a, ICollection b) + { + return ContainsAll(a, b) && ContainsAll(b, a); + } + + static bool ContainsAll(ICollection a, ICollection b) + { + foreach (DesignItem item in a) { + if (!b.Contains(item)) + return false; + } + return true; + } + + PropertyContainer propertyContainer = new PropertyContainer(); + + public PropertyContainer PropertyContainer { + get { return propertyContainer; } + } + #endregion + + public Control ToolsControl { + get { return WpfToolbox.Instance.ToolboxControl; } + } + + public override void Dispose() + { + propertyContainer.Clear(); + base.Dispose(); + } + + protected override void OnSwitchedTo(EventArgs e) + { + base.OnSwitchedTo(e); + if (designer != null && designer.DesignContext != null) { + WpfToolbox.Instance.ToolService = designer.DesignContext.Services.Tool; + } + } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj index 4d09d37117..71591c13fd 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj @@ -53,6 +53,8 @@ + + @@ -66,6 +68,11 @@ ICSharpCode.Core False + + {8035765F-D51F-4A0C-A746-2FD100E19419} + ICSharpCode.SharpDevelop.Widgets + False + {78CC29AC-CC79-4355-B1F2-97936DF198AC} WpfDesign.Designer diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.cs index 4732b4008b..9e1089a890 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.cs @@ -20,7 +20,7 @@ using ICSharpCode.WpfDesign.PropertyEditor; namespace ICSharpCode.WpfDesign.Designer { /// - /// Description of PropertyGrid. + /// Shows a list of properties; supports data binding. /// public partial class PropertyEditor : UserControl { @@ -32,7 +32,7 @@ namespace ICSharpCode.WpfDesign.Designer new FrameworkPropertyMetadata(null, _OnEditedObjectPropertyChanged)); /// - /// Creates a new PropertyGrid instance. + /// Creates a new PropertyEditor instance. /// public PropertyEditor() { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DragDropExceptionHandler.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DragDropExceptionHandler.cs new file mode 100644 index 0000000000..3ef7df9d65 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DragDropExceptionHandler.cs @@ -0,0 +1,24 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace ICSharpCode.WpfDesign.Designer +{ + /// + /// When the designer is hosted in a Windows.Forms application, exceptions in + /// drag'n'drop handlers are silently ignored. + /// Applications hosting the designer should specify a delegate to their own exception handling + /// method. The default is Environment.FailFast. + /// + public static class DragDropExceptionHandler + { + public static Action HandleException = delegate(Exception ex) { + Environment.FailFast(ex.ToString()); + }; + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs index a563cbd691..73617aa529 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs @@ -67,31 +67,39 @@ namespace ICSharpCode.WpfDesign.Designer.Services void OnDragOver(object sender, DragEventArgs e) { - if (e.Data.GetData(typeof(CreateComponentTool)) == this) { - e.Effects = DragDropEffects.Copy; - e.Handled = true; - } else { - e.Effects = DragDropEffects.None; + try { + if (e.Data.GetData(typeof(CreateComponentTool)) == this) { + e.Effects = DragDropEffects.Copy; + e.Handled = true; + } else { + e.Effects = DragDropEffects.None; + } + } catch (Exception ex) { + DragDropExceptionHandler.HandleException(ex); } } void OnDrop(object sender, DragEventArgs e) { - if (e.Data.GetData(typeof(CreateComponentTool)) != this) - return; - e.Handled = true; - - IDesignPanel designPanel = (IDesignPanel)sender; - DesignPanelHitTestResult result = designPanel.HitTest(e.GetPosition(designPanel), false, true); - if (result.ModelHit != null) { - designPanel.Focus(); + try { + if (e.Data.GetData(typeof(CreateComponentTool)) != this) + return; + e.Handled = true; - DesignItem createdItem = CreateItem(designPanel.Context); - AddItemWithDefaultSize(result.ModelHit, createdItem, e.GetPosition(result.ModelHit.View)); - } - - if (designPanel.Context.Services.Tool.CurrentTool is CreateComponentTool) { - designPanel.Context.Services.Tool.CurrentTool = designPanel.Context.Services.Tool.PointerTool; + IDesignPanel designPanel = (IDesignPanel)sender; + DesignPanelHitTestResult result = designPanel.HitTest(e.GetPosition(designPanel), false, true); + if (result.ModelHit != null) { + designPanel.Focus(); + + DesignItem createdItem = CreateItem(designPanel.Context); + AddItemWithDefaultSize(result.ModelHit, createdItem, e.GetPosition(result.ModelHit.View)); + } + + if (designPanel.Context.Services.Tool.CurrentTool is CreateComponentTool) { + designPanel.Context.Services.Tool.CurrentTool = designPanel.Context.Services.Tool.PointerTool; + } + } catch (Exception ex) { + DragDropExceptionHandler.HandleException(ex); } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj index 31151ec12c..6706aa3aaa 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj @@ -74,6 +74,7 @@ + diff --git a/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyContainer.cs b/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyContainer.cs index ff455cb872..0b7daf5e68 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyContainer.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyContainer.cs @@ -8,6 +8,7 @@ using System; using System.Collections; using System.ComponentModel.Design; +using System.Windows.Forms; namespace ICSharpCode.SharpDevelop.Gui { @@ -95,6 +96,16 @@ namespace ICSharpCode.SharpDevelop.Gui } } + Control propertyGridReplacementControl; + + public Control PropertyGridReplacementControl { + get { return propertyGridReplacementControl; } + set { + propertyGridReplacementControl = value; + PropertyPad.UpdatePropertyGridReplacementControl(this); + } + } + /// /// Clears all properties on this container. /// When a ViewContent is closed, it should call Clear on it's property container to @@ -105,6 +116,7 @@ namespace ICSharpCode.SharpDevelop.Gui Host = null; SelectableObjects = null; SelectedObject = null; + PropertyGridReplacementControl = null; } } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs b/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs index 380201570b..12216a2f28 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs @@ -30,9 +30,11 @@ namespace ICSharpCode.SharpDevelop.Gui if (pc == null) return; activeContainer = pc; + UpdateHostIfActive(pc); UpdateSelectedObjectIfActive(pc); UpdateSelectableIfActive(pc); + UpdatePropertyGridReplacementControl(pc); } internal static void UpdateSelectedObjectIfActive(PropertyContainer container) @@ -70,6 +72,27 @@ namespace ICSharpCode.SharpDevelop.Gui instance.SetSelectableObjects(container.SelectableObjects); } + internal static void UpdatePropertyGridReplacementControl(PropertyContainer container) + { + if (instance == null) return; + if (instance.activeContainer != container) + return; + LoggingService.Debug("UpdatePropertyGridReplacementControl"); + if (container.PropertyGridReplacementControl != null) { + if (!instance.panel.Controls.Contains(container.PropertyGridReplacementControl)) { + instance.panel.Controls.Clear(); + container.PropertyGridReplacementControl.Dock = DockStyle.Fill; + instance.panel.Controls.Add(container.PropertyGridReplacementControl); + } + } else { + if (!instance.panel.Controls.Contains(instance.grid)) { + instance.panel.Controls.Clear(); + instance.panel.Controls.Add(instance.grid); + instance.panel.Controls.Add(instance.comboBox); + } + } + } + Panel panel; ComboBox comboBox; PropertyGrid grid; diff --git a/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs b/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs index 0858a4b8df..19d3f25193 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs @@ -218,7 +218,6 @@ namespace ICSharpCode.SharpDevelop.Gui if (activeContent != value) { activeContent = value; if (ActiveContentChanged != null) { - Console.WriteLine(Environment.StackTrace); ActiveContentChanged(this, EventArgs.Empty); } } diff --git a/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/SideBar/SideBar.cs b/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/SideBar/SideBar.cs index 53663821d7..f92873e4e8 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/SideBar/SideBar.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/SideBar/SideBar.cs @@ -707,6 +707,14 @@ namespace ICSharpCode.SharpDevelop.Widgets.SideBar sideTabContent.Refresh(); } + protected virtual object StartItemDrag(SideTabItem draggedItem) + { + SpecialDataObject dataObject = new SpecialDataObject(); + dataObject.SetData(draggedItem.Tag); + dataObject.SetData(draggedItem); + return dataObject; + } + protected class SideTabContent : UserControl { SideBarControl sideBar = null; @@ -893,11 +901,8 @@ namespace ICSharpCode.SharpDevelop.Widgets.SideBar if (item != null) { if (IsDragStarted(mouseDownPos, e.Location)) { sideBar.Tabs.DragOverTab = sideBar.activeTab; - SpecialDataObject dataObject = new SpecialDataObject(); - dataObject.SetData(item.Tag); - dataObject.SetData(item); - DoDragDrop(dataObject, sideBar.activeTab.CanDragDrop ? DragDropEffects.All : (DragDropEffects.Copy | DragDropEffects.None)); + DoDragDrop(sideBar.StartItemDrag(item), sideBar.activeTab.CanDragDrop ? DragDropEffects.All : (DragDropEffects.Copy | DragDropEffects.None)); } Refresh(); }