Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 466375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:28:21+00:00 2026-05-12T23:28:21+00:00

I’m trying to host the Workflow Designer in a WPF application. The WorkflowView control

  • 0

I’m trying to host the Workflow Designer in a WPF application. The WorkflowView control is hosted under a WindowsFormsHost control. I’ve managed to load workflows onto the designer which is successfully linked to a PropertyGrid, also hosted in another WindowsFormsHost.

WorkflowView workflowView = rootDesigner.GetView(ViewTechnology.Default) as WorkflowView;
window.WorkflowViewHost.Child = workflowView;

The majority of the rehosting code is the same as in http://msdn.microsoft.com/en-us/library/aa480213.aspx.

I’ve created a custom Toolbox using a ListBox WPF control bound to a list of ToolboxItems.

<ListBox Grid.Row="1" Margin="0 0 0 4" BorderThickness="1" BorderBrush="DarkGray" ItemsSource="{Binding Path=ToolboxItems}" PreviewMouseLeftButtonDown="ListBox_PreviewMouseLeftButtonDown" AllowDrop="True">
 <ListBox.Resources>
  <vw:BitmapSourceTypeConverter x:Key="BitmapSourceConverter" />
 </ListBox.Resources>
 <ListBox.ItemTemplate>
  <DataTemplate DataType="{x:Type dd:ToolboxItem}">
   <StackPanel Orientation="Horizontal" Margin="3">
    <Image Source="{Binding Path=Bitmap, Converter={StaticResource BitmapSourceConverter}}" Height="16" Width="16" Margin="0 0 3 0"     />
    <TextBlock Text="{Binding Path=DisplayName}" FontSize="14" Height="16" VerticalAlignment="Center" />
    <StackPanel.ToolTip>
     <TextBlock Text="{Binding Path=Description}" />
    </StackPanel.ToolTip>
   </StackPanel>
  </DataTemplate>
 </ListBox.ItemTemplate>
</ListBox>

In the ListBox_PreviewMouseLeftButtonDown handler:

private void ListBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
 ListBox parent = (ListBox)sender;

 UIElement dataContainer;
 //get the ToolboxItem for the selected item
 object data = GetObjectDataFromPoint(parent, e.GetPosition(parent), out dataContainer);

 //if the data is not null then start the drag drop operation
 if (data != null)
 {
  DataObject dataObject = new DataObject();
  dataObject.SetData(typeof(ToolboxItem), data);

  DragDrop.DoDragDrop(parent, dataObject, DragDropEffects.Move | DragDropEffects.Copy);
 }
}

With that setup, I’m unable to drag any item from my custom Toolbox onto the designer. The cursor is always displayed as “No” anywhere on the designer.

I’ve been trying to find anything about this on the net for half a day now and I really hope some can help me here.

Any feedback is much appreciated. Thank you!

Carlos

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:28:21+00:00Added an answer on May 12, 2026 at 11:28 pm

    Finally got Drag and Drop working. There were three things that needed doing, for whatever reason WorkflowView has:

    1.) I had to use System.Windows.Forms.DataObject instead of System.Windows.DataObject when serializing the ToolboxItem when doing DragDrop.

    private void ListBox_MouseDownHandler(object sender, MouseButtonEventArgs e)
    {
        ListBox parent = (ListBox)sender;
    
        //get the object source for the selected item
        object data = GetObjectDataFromPoint(parent, e.GetPosition(parent));
    
        //if the data is not null then start the drag drop operation
        if (data != null)
        {
            System.Windows.Forms.DataObject dataObject = new System.Windows.Forms.DataObject();
            dataObject.SetData(typeof(ToolboxItem), data as ToolboxItem);
            DragDrop.DoDragDrop(this, dataObject, DragDropEffects.Move | DragDropEffects.Copy);
        }
    }
    

    2.) DragDrop.DoDragDrop source must be set to the IToolboxService set in the IDesignerHost. The control holding the ListBox implements IToolboxService.

    // "this" points to ListBox's parent which implements IToolboxService.
    DragDrop.DoDragDrop(this, dataObject, DragDropEffects.Move | DragDropEffects.Copy);
    

    3.) The ListBox should be bound to a list of ToolboxItems returned by the following helper method, passing it the Type of the activities to show in the tool box:

    ...
    this.ToolboxItems = new ToolboxItem[] 
        {
            GetToolboxItem(typeof(IfElseActivity))
        };
    ...
    
    internal static ToolboxItem GetToolboxItem(Type toolType)
    {
        if (toolType == null)
            throw new ArgumentNullException("toolType");
    
        ToolboxItem item = null;
        if ((toolType.IsPublic || toolType.IsNestedPublic) && typeof(IComponent).IsAssignableFrom(toolType) && !toolType.IsAbstract)
        {
            ToolboxItemAttribute toolboxItemAttribute = (ToolboxItemAttribute)TypeDescriptor.GetAttributes(toolType)[typeof(ToolboxItemAttribute)];
            if (toolboxItemAttribute != null && !toolboxItemAttribute.IsDefaultAttribute())
            {
                Type itemType = toolboxItemAttribute.ToolboxItemType;
                if (itemType != null)
                {
                    // First, try to find a constructor with Type as a parameter.  If that
                    // fails, try the default constructor.
                    ConstructorInfo ctor = itemType.GetConstructor(new Type[] { typeof(Type) });
                    if (ctor != null)
                    {
                        item = (ToolboxItem)ctor.Invoke(new object[] { toolType });
                    }
                    else
                    {
                        ctor = itemType.GetConstructor(new Type[0]);
                        if (ctor != null)
                        {
                            item = (ToolboxItem)ctor.Invoke(new object[0]);
                            item.Initialize(toolType);
                        }
                    }
                }
            }
            else if (!toolboxItemAttribute.Equals(ToolboxItemAttribute.None))
            {
                item = new ToolboxItem(toolType);
            }
        }
        else if (typeof(ToolboxItem).IsAssignableFrom(toolType))
        {
            // if the type *is* a toolboxitem, just create it..
            //
            try
            {
                item = (ToolboxItem)Activator.CreateInstance(toolType, true);
            }
            catch
            {
            }
        }
    
        return item;
    }
    

    GetToolboxItem method is from http://msdn.microsoft.com/en-us/library/aa480213.aspx source, in the ToolboxService class.

    Cheers,
    Carlos

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 217k
  • Answers 218k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No, there is no "previous sibling" selector. On a related… May 12, 2026 at 11:28 pm
  • Editorial Team
    Editorial Team added an answer Seeing the absence of any answer and the question looking… May 12, 2026 at 11:28 pm
  • Editorial Team
    Editorial Team added an answer Debian packages are like tar files - they contain a… May 12, 2026 at 11:28 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want use html5's new tag to play a wav file (currently only supported
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.