We're loading a ToolboxControl object for our rehosted designer by adding ToolboxItemWrapper objects. I'm wondering if it's possible to somehow retrieve the wrapped ToolboxItem itself from the wrapper object? I tried casting, that doesn't work ... and there doesn't seem to be any property getter.
what do you mean retrieving the wrapped toolboxitem from the wrapper object?
can you give me more details at which stage you want to retrieve the toolboxitem?
or can you send me your casting code to email@example.com so I can investigate for you?
The ToolboxItemWrapper.ToolboxItem property is an internal property, so you can't direct access it. Here is a sample code if you do want to use this internal property:
//e.g Assume we have already have a ToolboxItemWrapper ToolboxItemWrapper itemWrapper = new System.Activities.Presentation.Toolbox.ToolboxItemWrapper(typeof(Assign)); ToolboxControl toolbox = new ToolboxControl(); ToolboxCategory category = new ToolboxCategory(); category.Add(itemWrapper); toolbox.Categories.Add(category); //Use reflection to get the ToolboxItem instance from ToolboxItemWrapper PropertyInfo toolboxItemPropertyInfo = itemWrapper.GetType().GetProperty("ToolboxItem", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty); ToolboxItem item = toolboxItemPropertyInfo.GetValue(itemWrapper, null) as ToolboxItem;
Note: The toolboxItemWrapper.ToolboxItem property will not get calculated until you add this itemWrapper to a ToolboxControl. Before you add it, it's null.
Use internal property maybe not a good practice, please let Ye and me know why do you want ToolboxItem object.
This posting is provided "AS IS" and confers no rights or warranties.
- Edited by Yuanji WangMicrosoft employee, Moderator Thursday, October 14, 2010 5:30 AM Format is not good