Add a user control to a wpf window
Solution 1:
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 ..... />
Solution 2:
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>
Solution 3:
Make sure there is an namespace definition (xmlns
) for the namespace your control belong to.
xmlns:myControls="clr-namespace:YourCustomNamespace.Controls;assembly=YourAssemblyName"
<myControls:thecontrol/>