Share via


Prism for the Windows Runtime reference

[This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation]

From: Developing a Windows Store business app using C#, XAML, and Prism for the Windows Runtime

Previous page | Next page

Learn about the Prism for the Windows Runtime libraries that help developers create Windows Store business apps using C# and XAML. The libraries accelerate the development of apps by providing support for Model-View-ViewModel (MVVM), loosely coupled communication, state management, navigation, validation of user input, data binding, commands, and settings.

Download

After you download the code, see Getting started using Prism for the Windows Runtime for instructions on how to compile and run the reference implementation, as well as understand the Microsoft Visual Studio solution structure.

You will learn

  • About the classes and interfaces contained in the Microsoft.Practices.Prism.StoreApps library.
  • About the classes and interfaces contained in the Microsoft.Practices.Prism.PubSubEvents library.

Applies to

  • Windows Runtime for Windows 8.1
  • C#
  • Extensible Application Markup Language (XAML)

Prism helps developers create managed Windows Store apps. It accelerates development by providing support for MVVM, loosely coupled communication, and the core services required in Windows Store apps. It is designed to help developers create apps that need to accomplish the following:

  • Address the common Windows Store app development scenarios.
  • Separate the concerns of presentation, presentation logic, and model through support for Model-View-ViewModel (MVVM).
  • Use an architectural infrastructure to produce a consistent and high quality app.

Both libraries in Prism ship as source, with the Microsoft.Practices.Prism.PubSubEvents library also shipping as a signed binary.

Microsoft.Practices.Prism.StoreApps library

The Microsoft.Practices.Prism.StoreApps library is a class library that provides MVVM support with lifecycle management, and core services to a Windows Store app.

The following table lists the classes contained in the Microsoft.Practices.Prism.StoreApps library:

Class Description
AppManifestHelper Loads the package manifest and allows you to retrieve the application id, and check if the app uses the Search contract. This class can be extended to retrieve other app manifest values that are not exposed by the API.
BindableBase Implementation of the INotifyPropertyChanged interface, to simplify view model and model class property change notification.
BindableValidator Validates entity property values against entity-defined validation rules and exposes, through an indexer, a collection of errors for properties that did not pass validation.
Constants An internal class that contains constants used by the library.
DelegateCommand An ICommand implementation whose delegates do not take any parameters for Execute() and CanExecute().
DelegateCommand<T> An ICommand implementation whose delegates can be attached for Execute(T) and CanExecute(T).
DelegateCommandBase The base ICommand implementation whose delegates can be attached for Execute(Object) and CanExecute(Object).
FrameFacadeAdapter A facade and adapter class that implements the IFrameFacade interface to abstract the Frame object.
FrameNavigationService A service class that implements the INavigationService interface to navigate through the pages of an app.
MvvmAppBase Helps to bootstrap Windows Store apps that use the MVVM pattern, with services provided by the Microsoft.Practices.Prism.StoreApps library.
MvvmNavigatedEventArgs Provides data for navigation methods and event handlers that cannot cancel a navigation request.
ResourceLoaderAdapter An adapter class that implements the IResourceLoader interface to adapt the ResourceLoader object.
RestorableStateAttribute Defines an attribute that indicates that any marked property will save its state on suspension, provided that the marked property is in an instance of a class that derives from the ViewModel class.
SessionStateService A service class that implements the ISessionStateService interface to capture global session state in order to simplify process lifetime management for an app.
ValidatableBindableBase Implements the IValidatableBindableBase interface to validate model property values against their validation rules and return any validation errors.
ViewModel The base view model class that implements the INavigationAware interface to provide navigation support and state management to derived view model classes.
ViewModelLocator Locates the view model class for views that have the AutoWireViewModel attached property set to true.
VisualStateAwarePage The base view class for pages that need to be aware of layout changes and update their visual state accordingly.

 

The following table lists the interfaces contained in the Microsoft.Practices.Prism.StoreApps library:

Interface Description
ICredentialStore Defines an interface for the RoamingCredentialStore class that abstracts the PasswordVault object for managing user credentials.
IFlyoutViewModel Defines an interface that should be implemented by flyout view model classes to provide actions for opening and closing a flyout, and navigation away from the flyout.
IFrameFacade Defines an interface for the FrameFacadeAdapter class that abstracts the Frame object for use by apps that derive from the MvvmAppBase class.
INavigationAware Defines an interface that allows an implementing class to participate in a navigation operation.
INavigationService Defines an interface that allows an implementing class to create a navigation service.
IResourceLoader Defines an interface for the ResourceLoaderAdapter class that abstracts the ResourceLoader object for use by apps that derive from the MvvmAppBase class.
ISessionStateService Defines an interface that allows an implementing class to capture global session state.
IValidatableBindableBase Defines an interface that allows an implementing class to add validation support to model classes that contain validation rules.

 

For info about how this library was used in the AdventureWorks Shopper reference implementation, see Using the Model-View-ViewModel (MVVM) pattern, Creating and navigating between pages, Validating user input, Managing application data, Handling suspend, resume, and activation, Communicating between loosely coupled components, and Implementing search.

[Top]

Microsoft.Practices.Prism.PubSubEvents library

The Microsoft.Practices.Prism.PubSubEvents library is a Portable Class Library (PCL) that contains classes that implement event aggregation. You can use this library for communicating between loosely coupled components in your own app. The library has no dependencies on other libraries, and can be added to your Visual Studio solution without the Microsoft.Practices.Prism.StoreApps library. The PCL targets:

  • Microsoft .NET for Windows Store apps
  • .NET Framework 4 and higher
  • Microsoft Silverlight 4 and higher
  • Windows Phone 7 and higher
  • Xbox 360

For more info about portal class libraries, see Cross-Platform Development with the .NET Framework

The following table lists the classes contained in the Microsoft.Practices.Prism.PubSubEvents library:

Class Description
BackgroundEventSubscription<TPayload> Extends EventSubscription<TPayload> to invoke the Action delegate in a background thread.
DataEventArgs<TData> Generic arguments class to pass to event handlers that need to receive data.
DelegateReference Represents a reference to a Delegate that may contain a WeakReference to the target. This class is used internally.
DispatcherEventSubscription<TPayload> Extends EventSubscription<TPayload> to invoke the Action delegate in a specific Dispatcher.
EventAggregator Implements IEventAggregator.
EventBase Defines a base class to publish and subscribe to events.
EventSubscription<TPayload> Provides a way to retrieve a Delegate to execute an action depending on the value of a second filter predicate that returns true if the action should execute.
PubSubEvent<TPayload> Defines a class that manages publication and subscription to events.
SubscriptionToken Subscription token returned from EventBase on subscribe.

 

The following table lists the interfaces contained in the Microsoft.Practices.Prism.PubSubEvents library:

Interface Description
IDelegateReference Represents a reference to a Delegate.
IEventAggregator Defines an interface to get instances of an event type.
IEventSubscription Defines a contract for an event subscription to be used by EventBase.

 

The following table lists the enumerations contained in the Microsoft.Practices.Prism.PubSubEvents library:

Enumeration Description
ThreadOption Specifies on which thread a PubSubEvent<TPayload> subscriber will be called.

 

For info about publishing and subscribing to events, see Communicating between loosely coupled components and Event aggregation Quickstart.

[Top]