2

I use a third-party WPF control I installed with NuGet. I need to make a change to it, and source is available on GitHub. I have cloned the repo, but what do I do now?

Do I just copy the files into my project somewhere, or should I build the custom control as a separate project?

Specifically, it is https://github.com/snmslavk/WPF-Keyboard-Control

Tor Klingberg
  • 4,790
  • 6
  • 41
  • 51
  • 2
    "I have files. Should I make them a separate project or not?" That's not a question anybody can answer without a bit more detail. How many files? What kind of files? Is it just a .cs file and a .xaml file? How would you ordinarily decide whether to put something in a separate project? – 15ee8f99-57ff-4f92-890c-b56153 Aug 26 '16 at 14:54
  • 1
    I'd always make it a seperate control. It takes all the (mostly) overhead code out of your main application. Its just an additional feature. Why carry the whole code around all the time – lokusking Aug 26 '16 at 16:42

3 Answers3

2

You can either include all of this code in your project or build the DLL and just include the single DLL in your project as lokusking mentions in his comment as this will help reduce the overhead code and make your main project more readable.

So for this specific control, you will need to build the project after you made your changes and reference the TermControls.dll in your main application and then add the namespace to your XAML like so:

      xmlns:TermControls="clr-namespace:TermControls;assembly=TermControls"

Here is some more information on how to do this:

How to use custom Controls in WPF

Add a user control to a wpf window

Community
  • 1
  • 1
hcham1
  • 1,799
  • 2
  • 16
  • 27
2

hey Tor It's my component and I'm glad to hear that somebody uses it :)

If you want to use it as it is, just add dll to your project or install it with nuget.

If you want to contribute to github project then fork repo and create a pull request.

Do I just copy the files into my project somewhere, or should I build the custom control as a separate project?

From my opinion, both ways are correct. It depends just on your project and workflow in your team.

slava
  • 1,901
  • 6
  • 28
  • 32
1

Thank you for the answers. I got it working, and thought I should write down what I did.

  1. First remove the control and the directive at the top of the XAML file, and uninstall the library with NuGet. I think there would be a naming conflict otherwise.
  2. Copy the control source into the solutions base directory.
  3. Go into Add --> Existing Project and find the TermControls.csproj file.
  4. Build the project.
  5. Back in the main project, the custom control now shows up in the Toolbox. Add it like any other control.
Tor Klingberg
  • 4,790
  • 6
  • 41
  • 51