The WPF Workspace – Quick Start

Nuget Package:

PM> Install-Package HBD.WPF.Shell

As the Workspace for WPF had been introduced a few day back. So is this post I would like to show you how to get started with that application.

I.  Module Implementation.

1. Add New Project

  • Open Visual Studio and create a new WPF User Control Library project with project name is WPF.Demo.Module.
  • Install the latest version of HBD.WPF.Shell from Nuget.
  • Add a new class named DemoStartup and inherited from HBD.WPF.Shell.Modularity.WpfModuleBase and then override 2 methods (GetStartUpViewTypes and MenuConfiguration(IShellMenuService menuSet)) as below.
  • Remember to add the ModuleExport attribute into your DemoStartup class.

2. Setup the Module_*.json

  • Add a new json named Module_Demo.json with the below content.

  • Set the build action of this config file is Copy Alway.

3. Add a new User control

  • Add a new class named ViewModel1.cs inside folder ViewModels as below.

  • Add a new User Control named View1.xaml inside Views folder with the code behind as below.

4. Setup the Public folder

  • Copy folder [Solution Directory]\packages\HBD.WPF.Shell\tools\Shell to [Solution Directory]\Published\Shell.
  • Right click on the project select Properties
  • Add below code into Post-build event

  • Set Start external program under Debug to [Solution Directory]\Published\Shell\HBD.WPF.Shell.exe
  • And set Working directory to [Solution Directory]\Published\Shell folder.
Debug Setup

5. Run the application with this Module.

  • After finished all above steps, the project shall look like below.

  • Build and Run the application you will see the new Demo menu had been added. When clicking on the child menu item the View1 will be open on the Tab control.

II. Source Code

Download the WPF.Demo.Module here.

Hope my Workspace is useful.

Leave a Reply

Your email address will not be published. Required fields are marked *