locked
ToolboxItem Binding Error RRS feed

  • Question

  • I am rehosting the workflow designer, and populating the ToolboxControl as follows:

     

     

    var tbc = new ToolboxControl();

     

     

    var tbCategory = new ToolboxCategory("Control Flow");

    tbCategory.Add(

     

    new ToolboxItemWrapper(typeof(System.Activities.Statements.DoWhile), "DoWhile"));

    At runtime, each of my ToolboxItemWrapper instances generates the following error:

    System.Windows.Data Error: 40 : BindingExpression path error: 'ToolboxItem' property not found on 'object' ''ToolboxItemWrapper' (HashCode=48670844)'. BindingExpression:Path=ToolboxItem.DisplayName; DataItem='ToolboxItemWrapper' (HashCode=48670844); target element is 'TreeViewItem' (Name=''); target property is 'Name' (type 'String')

    Does anyone understand what's going on?


    Chuck Berg | Consulting Engineer | Corporate IT - Station Casinos, Inc.
    Saturday, February 27, 2010 2:28 AM

Answers

All replies

  • I can't repro your failures. your code miss one line for adding toolboxcategory to toolboxcontrol.categories can you try following code, it works on my machine Window win = new Window(); var tbc = new ToolboxControl(); var tbCategory = new ToolboxCategory("Control Flow"); tbCategory.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.DoWhile), "DoWhile")); tbc.Categories.Add(tbCategory); win.Content = tbc; win.ShowDialog();
    Monday, March 1, 2010 8:01 PM
  • I wasn't very clear.  My ToolboxControl appears to work just fine, except that I don't see the correct icons.  And in addition, the error mesages I described appear in the debugger Output Window.  Are the error messages "normal" or is there something wrong that just isn't visible?
    Chuck Berg | Consulting Engineer | Corporate IT - Station Casinos, Inc.
    • Proposed as answer by Ye Yu - MSFT Tuesday, March 2, 2010 2:18 AM
    Tuesday, March 2, 2010 2:00 AM
  • sorry, click a wrong button to propose your question as answer.

    can you have a try on my code first to see whether the icon can display correctly?

    Window win = new Window();
    var tbc = new ToolboxControl();
    var tbCategory = new ToolboxCategory("Control Flow");
    tbCategory.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.DoWhile), "DoWhile")); tbc.Categories.Add(tbCategory);
    win.Content = tbc;
    win.ShowDialog();
    Tuesday, March 2, 2010 2:19 AM
  • can you have a try at the code I pasted above to see whether the icon of the toolboxItem appearing correctly?

    if not, can you help paste a screenshot of your toolboxControl in rehost app?

    Tuesday, March 2, 2010 7:25 AM
  • Using your code I see the same error message in the Output Window, and I see the same incorrect icon (the blue gear) in the designer window.  I'm not able to paste a screen shot into this message control.


    Chuck Berg | Consulting Engineer | Corporate IT - Station Casinos, Inc.
    Tuesday, March 2, 2010 10:08 PM
  • if you are not setting any particular icons for your toolboxitem in rehost app.
    it will just show blue gear.
    this is correct.
    Tuesday, March 2, 2010 10:23 PM
  • OK, so how do I specify the icon that is associated with toolboxitems provided by Microsoft - such as "DoWhile"?

    And back to my original question, what is the error message:

    System.Windows.Data Error: 40 : BindingExpression path error: 'ToolboxItem' property not found on 'object' ''ToolboxItemWrapper' (HashCode=48670844)'. BindingExpression:Path=ToolboxItem.DisplayName; DataItem='ToolboxItemWrapper' (HashCode=48670844); target element is 'TreeViewItem' (Name=''); target property is 'Name' (type 'String')

    trying to tell me?
    Chuck Berg | Consulting Engineer | Corporate IT - Station Casinos, Inc.
    Tuesday, March 2, 2010 10:35 PM
  • in fact the toolboxcontrol in rehost app and the toolboxcontrol in VS are two different things.
    so if you want to display the icons as what you see in VS, you need to set yourself when you adding the item to toolboxcontrol in rehost.

    if sample code needed, please let me know.

    about that error message, I need to take a look first.

    Tuesday, March 2, 2010 10:45 PM
  • Thanks again for the update.  Sample code showing how to get the icons that appear in VS designer to appear in my rehosted designer would be great.

    I look forward to your feedback on the error message.


    Chuck Berg | Consulting Engineer | Corporate IT - Station Casinos, Inc.
    Tuesday, March 2, 2010 11:51 PM
  • I take a look at the error message.
    this is some "normal" things from WPF, so you can neglect it.
    Please give me some time, I will write a sample code for you and paste here tomorrow morning.
    Wednesday, March 3, 2010 12:15 AM
  • Hi Chuck,

    No toolbox icons is the default behavior for the rehosted toolbox and the error messages are ignorable.
    For custom toolbox items the easiest way to get something showing is to use the icon file name property on WorkflowToolboxItem.

    If you would rather have the OOB activities show up with their VS icons, someone posted a howto here:

    http://blogs.msdn.com/asgisv/archive/2010/02/10/displaying-net-framework-4-built-in-workflow-activity-icons-in-a-rehosted-workflow-designer.aspx

    For reusing OOB activities you may also be interested in a recent post on the right way to add certain items like ForEach to the toolbox (add a certain factory not the ForEach activity)(where I encountered the above link)

    Where are SendAndReceiveReply and ReceiveAndSendReply?

    Tim
    Wednesday, March 3, 2010 2:08 AM
  • you can use following code to add any icon for your toolboxitem. And you can create any icon for the toolboxitem yourself.
    static void Main(string[] args)
            {
                Window win = new Window();
                var tbc = new ToolboxControl();
                var tbCategory = new ToolboxCategory("Control Flow");
               
                tbCategory.Add(new ToolboxItemWrapper(typeof(DoWhile), @"G:\a.bmp", "DoWhile")); tbc.Categories.Add(tbCategory);
                win.Content = tbc;
                win.ShowDialog();
            }
    Wednesday, March 3, 2010 2:09 AM
  • Hi Tim,

    Thanks for the info.  I'm able to load icons for my custom activities using the filename property on WorkflowToolboxItem.  Is there no way to load icons from the resource file?


    Chuck Berg | Consulting Engineer | Corporate IT - Station Casinos, Inc.
    Wednesday, March 3, 2010 11:45 PM
  • Haven't tried it, but I think you could probably adapt the same sample howto show icons for built-in activities to show your own custom icons from a custom resource file also - by using the same attribute association code, but loading up your own resource instead.
    Tim
    Thursday, March 4, 2010 5:46 PM