How to create Drop Target realtime ?

Jul 7, 2010 at 2:22 PM


I tried Drag-Drop example its too good.

I want to create some textblock realtime and need to drop in list box. So what should I do to add drop event realtime for text block. I have tried this below code but it showing unhandled exception.

                DropTarget dt = new DropTarget();
                DragSource ds = new DragSource();
                ds.AllDropTargetsValid = true;
                ds.ShowReturnToOriginalPositionAnimation = false;
                ds.DropMode = DragSource.DropModeType.ReturnDragSource;
                ds.DragHandleMode = DragSource.DragHandleModeType.FullDragSource;
                ds.Tag = "HalfBattery";

                TextBlock tx = new TextBlock();
                tx.Text = "Hello1";

                ds.Content = tx;
                dt.Content = ds;
                dt.Ghost = tx;

                brdWrapper.Child = dt;


Please let me know what I am doing wrong.

Thanks in advance,

Laxmilal Menaria