Search code examples
wpfvisual-studio-2012user-controls

VS2012 - Add WPF existing user control to project


This seems like it should be pretty simple but I can't seem to make it happen. Lets say I have an existing project with a user control named uc1. I would like to use this user control in another project. I right-click the project name in the solution explorer and select add>existing item, change the drop down to all files and select the files uc1.xaml and uc1.xaml.vb. This of course adds the files to the project but there is no correlation between the xaml and the code behind file and there is no way to use the control. What is the proper way of doing this?


Solution

  • This of course adds the files to the project but there is no correlation between the xaml and the code behind file and there is no way to use the control. What is the proper way of doing this?

    Normally, you'd add a reference to the other project, and use the UserControl directly.

    This allows you to build a single project with your UserControl, and use the resulting assembly (DLL) in multiple projects without duplicating the code.