user4367090
user4367090

Reputation:

How to set a namespace for custom control

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

Upvotes: 1

Views: 1059

Answers (3)

Khale_Kitha
Khale_Kitha

Reputation: 254

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.

Upvotes: 0

David
David

Reputation: 17

Try to write this:

xmlns:local="clr-namespace:HelperLib"

Upvotes: 0

SYL
SYL

Reputation: 337

check Namespace of you class.

HelperLib its name of a class, but not namespace.

example

Upvotes: 0

Related Questions