.NET 7 and WinForms designer

Hi,

Does the latest .NET 7 compatible version of Alternet support Toolbox drag and drop?

Thanks.

Hi Sergey,

If I understand the question correctly, you’re asking about our WinForms Form Designer control compiled with .NET 7?

If so, there was an issue with adorner windows in .NET 7, causing issues with control resizing and drag-drop.

On our tests, it has been fixed in the latest versions (starting with .NET 7.0.9 )

Please let me know if this is not what yo meant.

Kind regards,
Dmitry

Dmitry,

Thanks for your reply. I should’ve expanded on my original question. Looks like WinForms designer toolbox works on .NET 7 windows apps (based on your reply). Expanded part is if you could point me at non-.NETFramewok, ie .NET 6 or 7, demo of WinForms toolbox integration I can play with, and also point out drag and drop initiation and handling on your toolbox implementation source code side I’d appreciate it.

A bit of background on that. My understanding is that SerializeAttribute’s been largely removed from most of .NET 7 classes, including ToolboxItem. On top of that binary formatter is obsolete now. Both of those pieces are used by DataObject and ToolboxItems classes when extracting the data from the dragged item. At least that’s how it works in .NET Framework designer stack. Reason for that is that WinForms designer expects drag and drop to adhere to a certain format, something that cannot be changed my understanding.

So I’m wondering if you made it work, somehow. Thanks.

Hi Sergey,

We use DesignerHost’s serialization mechanism to serialize ToolboxItem into DataObject.
Here’s the relevant code:

        private void StartDragAndDrop()
        {
            var dataObject = contentControl.ContentControlSite.SerializeItemForDragAndDrop(contentControl.SelectedItem);
            try
            {
                if (dataObject != null)
                    DoDragDrop(dataObject, DragDropEffects.Copy);
            }
            catch (Exception ex)
            {
                MessageBoxHandler.Show(ex.Message, ErrorMessages.ToolboxDragAndDropError, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        DataObject IToolboxContentControlSite.SerializeItemForDragAndDrop(ToolboxItem item)
        {
            if (DesignerHost == null)
                return CreateItemDataObjectForNoDesigner(item);

            return DesignerHost.Resolve<IToolboxService>().SerializeToolboxItem(item) as DataObject;
        }

Let me know if this is what you’re looking for.

Regards,
Dmitry