DesignerView.AllowDrop does not work with StateMachine RRS feed

  • Question

  • I want to re-host the workflow designer in WPF. Most of my workflows will contain a StateMachine. I need to drag and drop customized States to the StateMachine of the current WorkflowDesigner.

    I managed to implement the drag and drop feature on the main Activity of the DesignerView but it does not work with the StateMachine. (When I drag a State onto the designer, it is added on the top of the designer but not on the place I clicked.)

    I would like the dragged State to be positionned where the click has been performed - and not somewhere else.

    Here is a snippet of my code:

    public MainWindow()



           (new DesignerMetadata()).Register();

           toolboxControl = CreateToolbox();

           toolboxArea.Child = toolboxControl;




    private void InitializeDesigner()


    //Load workflow designer

    (new DesignerMetadata()).Register();

    WorkflowDesigner workflowDesigner = new WorkflowDesigner();


    //Get designer view

    System.Activities.Presentation.View.DesignerView designerView = workflowDesigner.Context.Services.GetService<System.Activities.Presentation.View.DesignerView>();

    designerView.AllowDrop = true;

    //Get StateMachine and states

    builderRoot = designerView.ActivitySchema as ModelItem;

    stateMachineModelItem = builderRoot.Properties["Implementation"].Value;


    StateMachine computedValues = builderRoot.Content.ComputedValue as StateMachine;

    //Drag and Drop Handlers

    RadDragAndDropManager.Options.Effects = DragDropEffects.All;

    RadDragAndDropManager.AddDropQueryHandler(designerView, OnDropQuery);

    RadDragAndDropManager.AddDropInfoHandler(designerView, OnDropInfo);

    RadDragAndDropManager.SetAllowDrop(designerView, true);

    RadDragAndDropManager.SetAllowDrop(workflowDesigner.View, true);


    private void OnDropQuery(object sender, DragDropQueryEventArgs e)



    box = e.Options.Destination as DesignerView;

           builderRoot = box.ActivitySchema as ModelItem;

           stateMachineModelItem = builderRoot.Properties["Implementation"].Value;

           StateMachine computedValues = builderRoot.Content.ComputedValue as StateMachine;



    private void OnDropInfo(object sender, DragDropEventArgs e)






    private void AddState(Activity activity)


           State state = new State()







    <Window x:Class="RadWindowAsMainWindow.Window1" xmlns:local="clr-namespace:RadWindowAsMainWindow" …>


    <local:IbisTasks />













                    Value="True" />





    <!—Toolbox for States-->



                       ItemsSource="{Binding IbisTaskList}" …                            






    Thursday, October 11, 2012 12:24 PM


  • Basically positions are not working because you reimplemented drag+drop instead of leveraging state machine's built in drop handling.

    If you use a drag drop format that state machine understands, then state machine will handle the drop for you.

    Otherwise you have to do the work of working out the coordinates, and setting the correct attached view state  values (such as you can see in XAML).

    I would recommend using a data format that state machine understands. The data format is discussed a little here:



    • Marked as answer by LeoTang Friday, October 19, 2012 8:55 AM
    Thursday, October 11, 2012 8:16 PM