6

I'm trying to add a reference to the namespace System.Windows.Controls in a library project but i can't find it in the list. Does anybody know what is going on? i'm using 4.0. thanks.

starblue
  • 55,348
  • 14
  • 97
  • 151
Ziad
  • 187
  • 2
  • 3
  • 13

3 Answers3

17

You need to learn to distinguish between assembly names and namespaces. They're not in a 1-1 correspondence.

If you're wanting to access e.g. System.Windows.Controls.Button, you need to reference the PresentationFramework assembly, which does seem to contain most of the classes documented on MSDN as being in the System.Windows.Controls namespace.

Multiple assemblies can contribute classes/controls to a single namespace. And there's no requirement that all (or even the majority) of classes from an assembly all reside within a single namespace.

Damien_The_Unbeliever
  • 234,701
  • 27
  • 340
  • 448
  • Actually my problem is a little bir bigger than that. I have a project of a class library. In this project i have mutiple user controls. These controls uses a class "A" that inherits from "Contol". I'm trying to make a mergd dictionary for all these user controls. In the styles that exists in this dictionary is used the class "A". and i'm having a run time problem loading this template because it can't create the type "A". i checked the problem and found that i have to add the reference System.Windows.Controls tot he project, but i didn't find it in the browser. – Ziad Aug 19 '11 at 07:31
  • 1
    @Ziad - still, I think the crux of your question, and the answer you need, is that you need to add a reference to `PresentationFramework`. If that's not it, you need to edit your question and provide more information on what problem you're having. – Damien_The_Unbeliever Aug 19 '11 at 07:33
  • 1
    @Ziad - there isn't an assembly called `System.Windows.Controls`. (Not in the framework anyway) – Damien_The_Unbeliever Aug 19 '11 at 07:41
  • @Damien_The_Unbeliver I think this is a better explanation, but i'm trying on a desktop application and i got the same problem. http://connect.microsoft.com/VisualStudio/feedback/details/605907/silverlight-4-xamlparseexception-failed-to-create-a-system-type-from-the-text-local-customerentity – Ziad Aug 19 '11 at 08:22
  • @Ziad - if you're working in Silverlight (your question just says WPF), then most of the controls are in the `System.Windows` assembly (note, still not `System.Windows.Controls`) – Damien_The_Unbeliever Aug 19 '11 at 08:34
0

The System.Windows ships with Silverlight toolkit. Hope that helps.

Geoffrey
  • 93
  • 3
  • 7
0

If you are using VS 2010: Check you project settings: right click your Project, select "Properties", then select the "Application" tab. If the Dropdown for "Target framework" is ".Net Framework 4 Client Profile" you have to change it to ".net Framework 4".

Edit: I guess the requried assembly is "PresentationFramework.dll" (see msdn class info about Usercontrol). My fault, Ijust thought it would the Client Profile, because I usualy make this error.

Bernhard Kircher
  • 4,132
  • 3
  • 32
  • 38
  • I'm very positive that `System.Windows.Controls` is available in the .NET client profile. Then again, worth a try. – BoltClock Aug 19 '11 at 07:07
  • My fault, edited my answer - I just thought it would be the Clientprofile and tested it locally. Since this is a common error i make, I thought this would be the problem. Since I do not develop Desktop applications, I am not an expert for the namespaces/assemblies. But MSDN helpds in doubt. – Bernhard Kircher Aug 19 '11 at 07:19