views:

435

answers:

3

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 cant figure out how to add it to the window.

I'm pulling my hair out here!

Any help is greatly appreciated!

+4  A: 

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 ..... />
Martin Harris
+1  A: 

You probably need to add the namespace:

<Window x:Class="UserControlTest.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:UserControlTest"
    Title="User Control Test" Height="300" Width="300">
    <local:UserControl1 />
</Window>
sixlettervariables
+2  A: 

couple of tips: first, make sure there is an xmlns at the top that includes the namespace your control lives in.

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

second, sometimes intellisense is stupid.

Muad'Dib
+1 for "sometimes intellisense is stupid.". Make sure that the project actually doesn't compile and run, I've lost track of the number of times VS has told me my xmal is invalid when all it needed was a rebuild to make it reconsider.
Martin Harris