Add a user control to a wpf window

WedTM picture WedTM · Jul 7, 2009 · Viewed 107.6k times · Source

I have a user control that I've created, however when I go to add it to the XAML in the window, Intellisense doesn't pick it up, and I can't figure out how to add it to the window.

Answer

Martin Harris picture Martin Harris · Jul 7, 2009

You need to add a reference inside the window tag. Something like:

xmlns:controls="clr-namespace:YourCustomNamespace.Controls;assembly=YourAssemblyName"

(When you add xmlns:controls=" intellisense should kick in to make this bit easier)

Then you can add the control with:

<controls:CustomControlClassName ..... />