How do you debug a WPF user control in design mode? How do you debug a WPF user control in design mode? wpf wpf

How do you debug a WPF user control in design mode?


Here are the steps to debug a control at design time:

  • Start a second instance of Visual Studio
  • Attach to the first instance from the Debug menu
  • In the second instance, open the source code of your control
  • Set breakpoints at appropriate locations
  • In the first VS instance, reload the designer

Note that this technique isn't limited to controls; you can also use it to debug VS extensions, or anything that executes within Visual Studio.


To debug Controls assembly, I use following solution.

  1. open project's properties using Project menu

  2. display Debug (Déboguer in french)

  3. Set Start extern program to devenv.exe (red rectangle)

    On my PC it is

    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe

  4. Fill arguments of command's line so that is is equal to solution's file (blue rectangle)

  5. Specify working directory. Since directory is not speficied in arguments, working directoring is equivalent to directory that contains .sln file. (green rectangle)

    On my PC it is

    D:\@Projets\VisualBasic.Net\Tramex.Controls.Net\Test

enter image description here

Now, the first time I start debugging, a new Visual Studio is started. This phase can leave some minutes (on my PC 5 minutes). But this is only for the first time I start the debug process.

I can then works with controls in Designer on second Visual Studio application and see what happens when a breakpoint define in first windows is raised.

This works perfectly well with WinForms controls.