February 1, 2015
Hot Topics:

Getting Up and Running with the Composite UI Application Block for WPF

  • September 29, 2008
  • By Jani Järvinen
  • Send Email »
  • More Articles »

When you install the .MSI package for SCSF, you also get a chance to install a copy of the source code for the block, and also several example and tutorial applications. By default, SCSF installs into the directory "C:\Program Files\Microsoft Smart Client Factory April 2008", under which you can find a subdirectory named "Source Code Installer". In turn, this directory has an installer file that allows you to install the source code set into any location you choose.

In the separately installed source code directory, you will find many Visual Studio solution (.sln) files. One of them is called "Quickstarts.WPFIntegration.sln", which is the one you should try first. When you open this solution, Visual Studio will look like Figure 2.

Click here for a larger image.

Figure 2: The sample WPF application opened up in Visual Studio 2008.

When you first try to build the solution, you will likely get error messages such as "The referenced assembly NN was not found" or "NN does not implement interface member MM". Although this sounds bad for a sample application, there is luckily an easy remedy: Update the references in each project part of the solution to point to correct assemblies.

If you chose the default installation directory, the correct assemblies are located in the "C:\Program Files\Microsoft Smart Client Factory April 2008\Lib" directory. From here, you will find assemblies such as Microsoft.Practices.CompositeUI and Microsoft.Practices.CompositeUI.WPF, which you need to add to the references manually, and remove the invalid references, if any.

Once you are done with the reference corrections, it is time to test whether the solution builds. Do a full rebuild (just in case), and if it succeeds, run the sample application and test it. It should work well, and you should be able to see the nice and smooth, yet interactive organization chart next to employee details. It is the application block doing its magic.

Exploring the Sample Application

Once you can build the WPF sample application "Quickstarts.WPFIntegration" successfully, it is time to take a quick look at how it is organized in Solution Explorer. Overall, the solution has two high-level solution folders: Blocks and Source. The Blocks folder contains the projects that form the three main building blocks of the CAB.

Source, on the other hand, contains the sample application code. If you expand this folder, you will find another solution folder named Infrastructure. This in turn contains four projects: the Shell, and then three more for application interfaces, modules, and libraries.

The execution starting point is in the Shell project. If you open up the file ShellApplication.cs, you will notice a class defined like this:

class ShellApplication : SmartClientApplication<
   WorkItem, ShellForm>

With this declaration, the ShellApplication class is defined using generics, so that the SmartClientApplication class (defined in the WPFIntegration.Infrastructure.Library project) knows the basic class types for the application main form and the work items.

The defined ShellApplication class has a regular static void Main() function, and contains startup code for the application. Notice how the Run method call differs slightly from a generic WinForms application Run method call:

private static void RunInDebugMode()
   new ShellApplication().Run();

After the Run call, the execution goes to the SmartClientApplication class's AddServices method. Here, the most important services are added to the collection maintained by the RootWorkItem class. This class is the main (root) work item for the whole project, and keeps track of all other work items in the project.

Page 2 of 3

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel