There are two ways to implement Drag & Drop interaction.

  1. Drag&Drop Event
  2. DataObject

Drag&Drop event

Method 1.

Drag&Drop File name as Math variable

Download sample

Video

CODE:

        private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
        {
            ScalarAttrInt attr = new ScalarAttrInt("x");

            DataObject newObject = new DataObject();
            newObject.SetData("Expression", attr);// use name "Expression"

            // drag&drop from ListView
            this.listView1.DoDragDrop(newObject, DragDropEffects.Copy);
        }

DataObject

Method 2.

You can use the name "Expression" and set a IExpression object to DataObject 

Download sample

Video

CODE:

        private void mathControl1_DragDropExpression(object sender, DragEventArgs e)
        {
            object fileNameObj = e.Data.GetData("FileName");

            if (fileNameObj == null)
                return;

            string fileName = System.IO.Path.GetFileNameWithoutExtension((fileNameObj as string[])[0]);

            ScalarAttrInt attr = new ScalarAttrInt(fileName);

            this.mathControl1.Paste(attr);
        }