TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Adding Module to Project in WPF
Kailash Chandra Behera
Oct 07, 2013
9.9
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
This blog defines how to add module to project in WPF.
Adding Module to Project
Add a new class library project to your solution. To dothis, right-click the your project solution node in SolutionExplorer, point to Add, and then click New Project. In the Projecttypes list, select Windows in the Visual C# node. In the Templatesbox, click Class Library. Finally, set the project's name tosimpleprismapplicationModule, and then click OK. The followingillustration shows your solution. Solution with a module namedsimpleprismapplicationmodule
Addreferences in your module to the following WPF assemblies. To dothis, right-click the simpleprismapplicationmoduleproject in Solution Explorer, and then click Add Reference. In theAdd Reference dialog box, click the .NET tab, click the followingassemblies, and then click OK:
PresentationCore.dll
PresentationFramework.dll
WindowsBase.dll
System.Xaml.dll
Add references in your module to the Microsoft.Practices.Prism.dll Prism Library assemblies. To do this, right-click theHelloWorldModule project in Solution Explorer, and then click AddReference. In the Add Reference dialog box, click the Browse tab,click the following assemblies, and then click OK:
Rename the Class1.cs file to simpleprismapplicationmodule.cs. Openthe file simpleprismapplicationmodule.cs and impliment theMicrosoft.Practices.Prism.Modularitynamespacein the class.
Implement the IModuleinterface in simpleprismapplicationmodule class and create theconstructure of this class.
Add a Views folder having name Viewto store the views of your application to thesimpleprismapplicationmodule project again add one more folder andrename to ViewModelto store the viewmodels.
Note
:- Above mentioned folders can be created in the simpleprismapplication project also, but it is good pratice to create a separate module to for manage code.
In your shell project,add a reference to the simpleprismapplicationmoduleproject. Open theBootstrapper.cs file and explore the ConfigureModuleCatalog method.The method implementation is shown in the following code.
protected override void ConfigureModuleCatalog()
{
base.ConfigureModuleCatalog();
}
Update theConfigureModuleCatalog method to register thesimpleprismapplicationmodule module with the module cataloginstance. To do this, you can add bellow codes in theConfigureModuleCatalog bellow the base.ConfigureModuleCatalog();code.
ModuleCatalog moduleCatalog= (ModuleCatalog)this.ModuleCatalog;
moduleCatalog.AddModule(typeof(simpleprismapplication.simpleprismapplicationmodule));
Now addin module andregister module application with shell is done next steps is addingview to application
Adding Module to Project in WPF
Next Recommended Reading
Adding Reference to WPF Toolkit Extended Assembly