locked
Problem adding user controls to my project. RRS feed

  • Question

  • Hi,
    I followed the following walkthrough\tutorial:
    http://msdn.microsoft.com/en-us/library/a6h7e207(VS.80).aspx
    This tutorial explains how to create an user control in one project and how to add the user control in another project. I am using VS 2005.
    However, when I create the project that tests the user control and the reference of the user control, the user control is not added to the toolbox.
    Why is this?
    I understand that there are 2 toolboxes. The first is the regular control toolbox and the second is the WPF toolbox. What is the difference?
    In the long run, I am interested in extending a windows control and replacing the existing control in an existing project. So I am from my understading I must create the create in a seperate project. Is this correct as well?
    Thanks for the help,
    Greenman
    Thursday, June 11, 2009 12:49 PM

Answers

  • Hello Greenman,

    Often the control won't appear until after you've added the project reference and been sure to rebuild the project...sometimes more than once, I've found.  Have you added them to the Toolbox?  Right-click on the toolbox ->Choose Items ->WPF Controls ->Browse... and click through to the bin directory in you control library and select the DLL.  

    I haven't had any luck in having them "auto-appear" as they do outside of WPF, but after you've added the reference and added the DLL to the toolbox I find that they appear after rebuilding the solution.  If not, drill back into your choose items menu and make sure they are selected in the WPF controls tab.

    You will be best served by using the control library to host your controls as you are doing.  This will promote the best re-use.

    There is a vast difference between the WinForms controls and the WPF controls, so you won't be inheriting from the opposite to serve the other project type, if you know what I mean (you don't inherit from a WinForm control as a base for something in WPF).

    Hope this helps.

    Cheers,
    -jc

    Me, coding and stuff: Mr. James
    • Edited by JamesChambers Thursday, June 11, 2009 2:49 PM formatting, little bit more info
    • Marked as answer by Jim Zhou - MSFT Wednesday, June 17, 2009 12:41 PM
    Thursday, June 11, 2009 2:48 PM

All replies

  • Hello Greenman,

    Often the control won't appear until after you've added the project reference and been sure to rebuild the project...sometimes more than once, I've found.  Have you added them to the Toolbox?  Right-click on the toolbox ->Choose Items ->WPF Controls ->Browse... and click through to the bin directory in you control library and select the DLL.  

    I haven't had any luck in having them "auto-appear" as they do outside of WPF, but after you've added the reference and added the DLL to the toolbox I find that they appear after rebuilding the solution.  If not, drill back into your choose items menu and make sure they are selected in the WPF controls tab.

    You will be best served by using the control library to host your controls as you are doing.  This will promote the best re-use.

    There is a vast difference between the WinForms controls and the WPF controls, so you won't be inheriting from the opposite to serve the other project type, if you know what I mean (you don't inherit from a WinForm control as a base for something in WPF).

    Hope this helps.

    Cheers,
    -jc

    Me, coding and stuff: Mr. James
    • Edited by JamesChambers Thursday, June 11, 2009 2:49 PM formatting, little bit more info
    • Marked as answer by Jim Zhou - MSFT Wednesday, June 17, 2009 12:41 PM
    Thursday, June 11, 2009 2:48 PM
  • James,
    Thanks a lot.
    I hadn't added them to the toolbox. I sort of expected that it would do it by default. Also, the tutorials didn't add that that useful piece of information.
    Again, thanks,
    Oded 
    Monday, June 22, 2009 8:21 AM