Add Class Library to WPF project

Hi I created Class Library which works if it's added to the project as a complete project. I can call it from demo like this:
 xmlns:control="clr-namespace:MyCustomControls;assembly=MyCustomControls"
How can I add it as a dll to the project ?
I did like this:
1. Add reference to library (to MyCustomControls.dll)
2.   xmlns:control="clr-namespace:MyCustomControls;assembly=MyCustomControls"
Nothing happens when I run the application.
What I do wrong?
LVL 1
mastiSoftAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chinmay PatelChief Technical NinjaCommented:
Both the two points you have mentioned are just referencing your assembly, you have to call a method or create an instance of a class from your assembly. What exactly your Assembly does?
0
mastiSoftAuthor Commented:
it creates a custom interface for form.  Here I send two screen shots. One is the output and the second is how it is woks (when the project is a part of another project)
Capture.PNG
HereItWorks.PNG
0
MishaProgrammerCommented:
May ne you should add your controls from your library in your base project(form)?
Also may be some problmes in your dll?

Do you  change  on Application tab Output type from Windows Application to Class Library

Do you select WPF > User Control (WPF), when you add your dll to your project? (To use XAML add reference to Windows.XAML assembly (Project > right click on References > Add Reference > from Assemblies add Windows.XAML ))

Also you should use this code in your main project:
<Window  
xmlns:lib="clr-namespace:MyCustomControls;assembly=MyCustomControls"
>
<lib:UserControl1 /> <!-- your Control from the library -->
</Window>

Open in new window

0
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

mastiSoftAuthor Commented:
we can forget about my control and talk in general. I have another one  the one I know is works I renamed it to be able add as attached file (it is not txt but dll)
I put the dll file into bin/Debug and add reference to this dll
in C# I include using MyCustomControls;
How do I apply this user control to my .xaml to apply this control to my project? Do I have to add something to App.xaml or what?
I was looking in Internet but all I find is how to create the User Control not how to use existing.
MyCustomControls.txt
0
MishaProgrammerCommented:
Why you add your dll in folder bin/Debug ? When you compile your project, library usually are copied in this folder. It is better, if you create own folder, for example, "Mylibrary", put there your dll and then add reference to this dll.
0
mastiSoftAuthor Commented:
I added the reference to dll and added dll to the project. Nothing helps. It have to exist tutorial about how to add user control to WPF project but I can't find it.
Screen-Shot-04-07-18-at-01.55-PM.PNG
0
Chinmay PatelChief Technical NinjaCommented:
If you really need to create a custom interface for your forms, I strongly suggest you use: https://github.com/MahApps/MahApps.Metro

either as a base to start OR entire project itself.

Now coming to the second part of your query, You have function xyz in assembly MyAssembly. You have a project MyProject and you want to consume functionality from MyAssembly.

Now if you just want to call the function xyz and get the result back, after adding the references, you can instantiate the class like this

MyAssembly assembly = new MyAssembly();
assembly.xyz();

If you want to provide a UI from your assembly, I suggest you read this articles from Microsoft's documentation https://docs.microsoft.com/en-us/dotnet/framework/wpf/controls/control-authoring-overview
and also check this Walk-through https://docs.microsoft.com/en-us/dotnet/framework/wpf/controls/walkthrough-create-a-button-by-using-xaml
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mastiSoftAuthor Commented:
thank you very much Mr.Chinmay Patel.
0
Chinmay PatelChief Technical NinjaCommented:
Glad I could help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WPF

From novice to tech pro — start learning today.