Click here to Skip to main content
13,146,014 members (43,935 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I created and compiled a WPF UserControl Library using VS 2008 .NET 3.5 on a Vista machine.
Then I created a simple WPF Windows application. I added a reference to the compiled UserControl Library. Now when I try to a namespace in the XMAL code for the window I do not see my compiled UserControl namespace.
What am I missing?
Posted 27-Nov-10 6:57am
Updated 27-Nov-10 8:36am
Henry Minute225.8K
JF2015 27-Nov-10 12:59pm
Edited to remove <pre> tag since they are supposed to be used for code only.
Henry Minute 27-Nov-10 13:31pm
Did you add a namespace reference (xmlns) in your .xaml file?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

After you've added the reference, you can call the UserControl directly from the code behind, like this:
public partial class MainWindow : Window
        public MainWindow()
            this.Content = new WpfControlLibrary1.UserControl1();

If you want to use it from the XAML code, use this:
<Window x:Class="WpfApplication1.MainWindow"
        Title="MainWindow" Height="350" Width="525">
        <lib:UserControl1 />

The xmlns:lib attribute of the Window element, maps the xml namespace lib to the WpfControlLibrary1 namespace. This is the syntax:

I hope this helped you!

remember to recompile the whole solution, otherwise, the IntelliSense won't be able to detect the new namespace!
Tarun.K.S 28-Nov-10 1:43am
Good Answer!
69Icaro 28-Nov-10 5:11am
Thanks! I'm very happy when I can help people!
Tarun.K.S 28-Nov-10 12:33pm
Great! have a 5!
69Icaro 29-Nov-10 16:20pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Thanks 691caro and the rest. I have done exactly what 691caro suggested and it doesn't work. my compiled dll is external to the current solution. If I run the app, it works. But the problem is that I do not see my namespace to insert it in the xaml file. is that normal behaviour? and also, as soon as I manually add the namespace the designer complains that I cannot load, is this a problem with visual studio 2008.
Also, do you guys have or can direct me where I can take a look at some smaple code showing the use of a UserControl using data binding to a business object, say a person object, and which uses DependencyProperty properties? The examples I have seen about UserControls and databinding using DependencyProperty properties 99% of them only have one property. I would like to see one that uses a customer or a person object, something more realistic.

Thank you in advance. I really appreciate it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170915.1 | Last Updated 28 Nov 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100