none
How can I drag and drop a xaml activity to a rehosted designer? RRS feed

  • Question

  • Hi,

    I understand that by dragging an item from the toolbox and dropping it on the designer, an empty activity of that type will be inserted on the designer at the drop location.

    One can also drag an activity from the designer and drop it on another location in the designer, the dragged activity will be inserted at the drop location as well.

    Is it possible that similar to these two drag and drop mechanism, I can drag a xaml activity to the designer? What I have in mind is this,

    Let's say you have a ListView containing several xaml files. I want to be able to drag one of the ListView item (ie one of the xaml files), and when I drag it over the designer it will act as if I drag something from the toolbox (except the activity will be supplied from the xaml). I know I can create a runtime activity from the file by using ActivityXamlServices.Load(filename), and I want this activity to be inserted at the drop location. But how to tell the application to understand this when I drag and drop?

    Wednesday, December 29, 2010 10:01 AM

Answers

  • You can use this.

    EditingContext.
                        Services.GetService<ModelTreeManager>().
                        CreateModelItem(null, activityx)
    Tim

    • Marked as answer by Louis Rhys Monday, January 3, 2011 7:37 AM
    Friday, December 31, 2010 3:00 AM
    Moderator
  • Hi Louis,
    I replied in the blog comments, does it answer your question?
    Tim
    • Marked as answer by Louis Rhys Monday, January 3, 2011 7:39 AM
    Thursday, December 30, 2010 10:01 PM
    Moderator

All replies

  • looking at this blogpost (Nick's comment in the comment section) would it possible to do that using DragDrop.DoDragDrop? what would be the DataObject?
    Thursday, December 30, 2010 4:20 PM
  • Hi Louis,
    I replied in the blog comments, does it answer your question?
    Tim
    • Marked as answer by Louis Rhys Monday, January 3, 2011 7:39 AM
    Thursday, December 30, 2010 10:01 PM
    Moderator
  • Hi Tim,

    Thanks for your reply. I am quoting it:

     

    "I think it should work with ModelItemDataFormat. You will want to avoid adding (dragging) the same activity object instance to two different places in the workflow, because that is not valid for runtime. So make sure you 'new up' the activity instance each time."

     

    What should be the DataObject instance that I pass to DragDrop.DoDragDrop ? The data must be a ModelItem? How to create a  model item out of an Activity?

    Friday, December 31, 2010 2:09 AM
  • You can use this.

    EditingContext.
                        Services.GetService<ModelTreeManager>().
                        CreateModelItem(null, activityx)
    Tim

    • Marked as answer by Louis Rhys Monday, January 3, 2011 7:37 AM
    Friday, December 31, 2010 3:00 AM
    Moderator