Locked UserControl Issue

  • Sunday, October 21, 2007 5:45 PM
     
     

    I have a userControl, I need to know how can I add it to the toolbox if its possible. and how can I set its Icon(ToolbooxBitmap Icon).

All Replies

  • Tuesday, October 23, 2007 7:22 AM
    Moderator
     
     
    This is a designer problem. Moving from WPF forum.

     

  • Tuesday, October 23, 2007 5:30 PM
    Owner
     
     Answered
    1. Add an image to your user control assembly with the following naming convention <control class name>.icon.<ext>, such as "UserControl1.icon.png" and set its BuildAction property to "Embedded Resource".
    2. Build the user control assembly.
    3. With a WPF Design tab activated go to the Toolbox, right click and select "Choose Toolbox Items"
    4. Click the "Browse..." button on the WPF Components tab and navigate to your user control assembly.
    5. Your user control should now show up in the list together with the icon you added.
    6. Click "OK" to add your user control to the Toolbox.
  • Tuesday, October 23, 2007 11:13 PM
    Moderator
     
     
    Note as well that by using a metadata assembly (http://blogs.msdn.com/jnak/archive/2007/08/10/adding-design-time-metadata-to-cider-and-blend.aspx) you can also use the ToolboxBrowsableAttribute to control which types within your assembly will be listed in the add items toolbox UI.
  • Thursday, October 25, 2007 6:16 AM
     
     

    I already follow these steps but I get the following error" There are no component in MyControl.dll that can be place on the toolbox. but I have 3 Controls in that assembly,

     

    Thanks,

     

     

  • Saturday, October 27, 2007 9:20 PM
    Moderator
     
     Answered

    Are you doing this from the "WPF Components" tab of the Choose Toolbox Items dialog and not the .Net tab?  That is important.  If you are, then what are the base classes of your components?

     

    Jim

  • Sunday, October 28, 2007 12:27 PM
     
     
    There is no "WPF Components" tab. I just have .Net and COM components.

     

  • Monday, October 29, 2007 2:20 PM
    Owner
     
     
    What version of Visual Studio are you using? We didn't add the WPF Components tab until Visual Studio 2008 Beta 2. The .Net Components tab only knows about Windows Forms controls - you cannot add any WPF user controls that way.

     

  • Monday, October 29, 2007 8:51 PM
     
     

    I am using VS2005, so there is no way or workaround to do that in VS2005

  • Monday, October 29, 2007 9:00 PM
    Owner
     
     Answered
    No, I'm sorry. The WPF support for VS 2005 was a very early prototype of our designer with a very limited feature set and is not recommended for use in a production environment.
  • Friday, November 23, 2007 6:17 PM
     
     

    Thanks Marco for solution to add custom icons for custom WPF controls. One more problem in this field:

     

    i.e.  I'm inheriting from some standard control 

    class MyButton: System.Windows.Controls.Button

     

    Question is: How to define that I would like to use standard Button icon in Visual Studio Toolbox for my custom control? Now I see some crossed squares as icons near my custom controls inherited form standard controls.

     

    One point to mention is if I add controls manually (not using ToolboxControlsInstaller) by using Choose Items in Toolbox then my custom controls inherited from standard controls have correct icons.

    Testing on VS 2008 RTM + VS 2008 SDK

     

    Thanks
  • Tuesday, November 27, 2007 7:57 PM
    Owner
     
     Answered

    Saulius,

     

    The reason why this works from the Choose Items dialog is that these icons are part of our WPF Designer package assembly Microsoft.VisualStudio.Xaml but not part of the ToolboxControlsInstaller.

     

    Feel free to use our icons by doing the following:

    • copy %WINDIR%\assembly\GAC_MSIL\Microsoft.VisualStudio.Xaml\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Xaml.dll to a local directory (Reflector had issues seeing this assambly in the GAC on my nachine)
    • open it with Reflector
    • save the icon from the Resources section locally to use them for your UserControl
  • Thursday, January 28, 2010 11:26 AM
     
     

    Also add theese lines in the code of the control :

    Imports Microsoft.Windows.Design

    <ToolboxBrowsable(True)> _