1

I have been implementing this solution explained here to make an outlinedTextbox.

I have created a test project and added directly in the main namespace and it works.

Now I want to add it to a library (HelperLib) and want to use it in whatever program of mine I want. For example here the program is called pcdLoggerS2.

enter image description here

but when I add it to my xaml it says that

enter image description here

so it's a matter of namespaces. Therefore I have add this

xmlns:local="clr-HelperLib"

in my definition of my Base:WindowViewBase but nothing has changed but it's really in that namespace!

enter image description here

--ADD FOR DAVID--- enter image description here

Community
  • 1
  • 1
Luca
  • 918
  • 2
  • 13
  • 30

3 Answers3

1

You need to make sure that you've added the HelperLib project as a reference to your test project.

Open PcdLogger and right click on References, and add that project as a reference. Until you do this, the XAML in your test project will not be able to find the correct assembly.

Additionally, when you reference a namespace, from another assembly, you need to add that information to the namespace declaration in your XAML.

(See: https://msdn.microsoft.com/en-us/library/bb514546%28v=vs.90%29.aspx)

As an example: (I would suggest leaving local for your local namespaces)

xmlns:helper="clr-namespace:HelperLib;assembly=HelperLib"

EDIT: Additionally, Visual Studio's intellisense is fond of telling you that the namespace, or class, does not exist until you have built the project. You may have to rebuild and/or close/reopen the xaml file for intellisense to cooperate again.

Khale_Kitha
  • 264
  • 1
  • 10
  • I have added your line and again it says: The name OutlinedTextBox does not exist in namespace "clr-namespace:HelperLib;Assembly=BelperLib" but if I right click and go to definition it leads me to the right class. The helperLib is added as an additional project. What else might be wrong? – Luca Feb 15 '16 at 17:12
  • Did you misspell HelperLib (BelperLib) or is that the actual error? Also, have you attempted to run it? The editor likes to, frequently, tell you that something doesn't exist, in XAML, if you haven't rebuilt, yet. – Khale_Kitha Feb 15 '16 at 17:14
  • Naaa that is so STUPID!! it works but the editor keeps on saying it's wrong. So please post it as a solution so that i can reward you. And then: am I bound not to use the editor anymore?!?!?! – Luca Feb 15 '16 at 17:19
  • I've added the additional information to this answer :) – Khale_Kitha Feb 15 '16 at 17:29
0

check Namespace of you class.

HelperLib its name of a class, but not namespace.

example

SYL
  • 337
  • 4
  • 16
0

Try to write this:

xmlns:local="clr-namespace:HelperLib"
David
  • 17
  • 1
  • 6
  • While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. – ryanyuyu Feb 15 '16 at 17:26