Apr 21

Prism Interview Questions and Answers


Prism Interview Questions and Answers

1. What is Prism? 

Prism is the framework or the set of guidelines which is used to develop the WPF desktop application as well as the Silverlight Rich Internet applications(RIA). So it’s a kind of Design pattern to Develop the XMAL based application. It also used to develop the Windows 7 applications. Prism mainly helps to design the loosely coupled components which can be easily integrated with the other components of the overall application. Prism mainly used to build the composite applications which need various other components to be integrated.

Prism has RegionManager, EventAggregator and Commands all with the purpose of solving decoupling issues related to UI components.

Prism mainly guides of creating the applications using the Model-View-ViewModel (MVVM) model, Managed Extensibility Framework (MEF), and navigation in the application.

To use the Prism framework, we need to use their library called as Prism Library. So prism Library is the in-built set of components which can be used in developing the WPF and Silverlight applications.

Benefits of PRISM are given below :

  • Modular development: – As we are developing components as independent units we can assign these units to different developers and do modular parallel development. With parallel development project will be delivered faster.
  • High re-usability: – As the components are developed in individual units we can plug them using PRISM and create composed UI in an easy way.

2. What are objectives of Prism?

Following are the objectives of using Prism.

  • Create an application from modules that can be built, assembled, and, optionally, deployed by independent teams using WPF or Silverlight.
  • Minimize cross-team dependencies and allow teams to specialize in different areas, such as user interface (UI) design, business logic implementation, and infrastructure code development.
  • Use an architecture that promotes reusability across independent teams.
  • Increase the quality of applications by abstracting common services that are available to all the teams.
  • Incrementally integrate new capabilities.

3. What is Dependency Injection?

Dependency Injection is a practice where objects are designed in a manner where they receive instances of the objects from other pieces of code, instead of constructing them internally. This means that any object implementing the interface which is required by the object can be substituted in without changing the code, which simplifies testing, and improves decoupling.

Let’s assume that we have object dependency when an object ‘x’ uses an object ‘y’, we say that ‘x’ is dependent on ‘y’. Object dependency becomes a problem when object ‘x’ needs to use another object dynamically, object ‘z’, instead of ‘y’. Strong dependency mixes both object (Data) and relation (logic) in one place and result in tight coupling that render the code much harder to modify and adjust. Dependency injection allows objects to relate to each other but through an interface so that object ‘x’ will use interface ‘i’ while both ‘y’ & ‘z’ implement the interface ‘i’. This methodology allows the isolation between the implementation, creation, and logical dependency of an object.

The Prism Library includes the UnityBootstrapper and MefBootstrapper classes, which implement most of the functionality necessary to use either Unity or MEF as the dependency injection container in your application. In addition to the stages shown in the previous illustration, each bootstrapper adds some steps specific to its container.

4. What is an Event Aggregator?

EventAggregator is the utility service which contains the events and allows the decouple the publisher and subscriber so that they can be buildup independently. Decouple is primarily useful when a new module needs to be added or removed or modified. The new module can be added as per the event fired and defined in the shell.

The EventAggregator service is primarily a container for events that allow decoupling of publishers and subscribers so they can evolve independently. This decoupling is useful in modularized applications because new modules can be added that respond to events defined by the shell or, more likely, other modules.

In the Composite Application Library, EventAggregator allows subscribers or publishers to locate a specific EventBase. The event aggregator also allows for multiple publishers and multiple subscribers, as shown in figure below.
The EventAggregator class is offered as a service in the container and can be retrieved through the IEventAggregator interface. The event aggregator is responsible for locating or building events and for keeping a collection of the events in the system.

The real work of connecting publishers and subscribers is done by the CompositePresentationEvent class. This is the only implementation of the EventBase class that is included in the Composite Application Library. This class maintains the list of subscribers and handles event dispatching to the subscribers.

5. What is Shell?

The shell is the main window of the application where the primary user interface (UI) content is contained. The shell may be composed of multiple windows if desired, but most commonly it is just a single main window that contains multiple views. The shell may contain named regions where modules can specify the views that will appear. It may also define certain top-level UI elements, such as the main menu and toolbar. The shell defines the overall appearance for the application. It may define styles and borders that are present and visible in the shell layout itself, and it may also define styles, templates, and themes that get applied to the views that are plugged into the shell. 

6. What is view? 

Views are the composite portions of the user interface that are contained in the shell’s window(s). It is easiest to think about a view as a user control that defines a rectangular portion of the client area in the main window. However, views in the Composite Application Library do not have to be defined with a user control. You can use a Windows Presentation Foundation (WPF) data template to define a view that will be rendered based on the data in your model. A view could also share screen real estate with other views due to the rendering and compositing capabilities of WPF. In simple terms, a view is just a collection of user interface elements that define part of the rendering of the user interface. It is a unit of encapsulation for defining the separable portions of your UI.

7. What is Bootstrapper?

Bootstrapper is an utility in WPF engine which is mainly responsible for the initialization of the application by using the composite application library. By using the bootstrapper we can find out how the components of the application are wired up in the composite application library. The bootstrapper responsibility to create the Shell or main window. Composite application library has the default abstract class UnityBootstrapper which actually handles the initialization.

A bootstrapper is a class that is responsible for the initialization of an application built using the Prism Library. By using a bootstrapper, you have more control of how the Prism Library components are wired up to your application.

The Prism Library includes a default abstract Bootstrapper base class that can be specialized for use with any container. Many of the methods on the bootstrapper classes are virtual methods. You can override these methods as appropriate in your own custom bootstrapper implementation.

8. What are the basic stages of bootstrapping process? 

Basic stages of the bootstrapping process are as follows.

The Prism Library provides some additional base classes, derived from Bootstrapper, that have default implementations that are appropriate for most applications. The only stages left for your application bootstrapper to implement are creating and initializing the shell.

9. What is Module in Prism?

Modules are classes that implement the IModule interface

Modules can be registered in following ways :

  • Directly inside code
  • Using Configuration
  • Using Directory Inspection

Module can have dependency on other module. Prism provides module dependency management.

Core Prism library is container agnostic. The following are examples of containers that are used as
dependency injection containers in Prism.

  • ModularityWithMef
  • ModularityWithUnity

10. How do you register modules?

Bootstrapper override CreateModuleCatalog and ConfigureModuleCatalog methods.

Permanent link to this article: http://zappmania.in/2013/04/21/prism-interview-questions-and-answers.htm


  1. Hi Seema,
    Please Give a simple example for clear understandable of page navigation in WPF Application.

    Rahul Kumar

    1. Hi Rahul, We have update the post and included a few links which can help you.
      Happy coding….

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.