Prism for the Windows Runtime reference

Applies to Windows only

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

Patterns & Practices logo

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

Download AdventureWorks Shopper sample
Download Prism StoreApps library
Download Prism PubSubEvents library
Download book (PDF)

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

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:

ClassDescription
AppManifestHelperLoads 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.
BindableBaseImplementation of the INotifyPropertyChanged interface, to simplify view model and model class property change notification.
BindableValidatorValidates entity property values against entity-defined validation rules and exposes, through an indexer, a collection of errors for properties that did not pass validation.
ConstantsAn internal class that contains constants used by the library.
DelegateCommandAn 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).
DelegateCommandBaseThe base ICommand implementation whose delegates can be attached for Execute(Object) and CanExecute(Object).
FrameFacadeAdapterA facade and adapter class that implements the IFrameFacade interface to abstract the Frame object.
FrameNavigationServiceA service class that implements the INavigationService interface to navigate through the pages of an app.
MvvmAppBaseHelps to bootstrap Windows Store apps that use the MVVM pattern, with services provided by the Microsoft.Practices.Prism.StoreApps library.
MvvmNavigatedEventArgsProvides data for navigation methods and event handlers that cannot cancel a navigation request.
ResourceLoaderAdapterAn adapter class that implements the IResourceLoader interface to adapt the ResourceLoader object.
RestorableStateAttributeDefines 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.
SessionStateServiceA service class that implements the ISessionStateService interface to capture global session state in order to simplify process lifetime management for an app.
ValidatableBindableBaseImplements the IValidatableBindableBase interface to validate model property values against their validation rules and return any validation errors.
ViewModelThe base view model class that implements the INavigationAware interface to provide navigation support and state management to derived view model classes.
ViewModelLocatorLocates the view model class for views that have the AutoWireViewModel attached property set to true.
VisualStateAwarePageThe 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:

InterfaceDescription
ICredentialStoreDefines an interface for the RoamingCredentialStore class that abstracts the PasswordVault object for managing user credentials.
IFlyoutViewModelDefines 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.
IFrameFacadeDefines an interface for the FrameFacadeAdapter class that abstracts the Frame object for use by apps that derive from the MvvmAppBase class.
INavigationAwareDefines an interface that allows an implementing class to participate in a navigation operation.
INavigationServiceDefines an interface that allows an implementing class to create a navigation service.
IResourceLoaderDefines an interface for the ResourceLoaderAdapter class that abstracts the ResourceLoader object for use by apps that derive from the MvvmAppBase class.
ISessionStateServiceDefines an interface that allows an implementing class to capture global session state.
IValidatableBindableBaseDefines 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:

ClassDescription
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.
DelegateReferenceRepresents 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.
EventAggregatorImplements IEventAggregator.
EventBaseDefines 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.
SubscriptionTokenSubscription token returned from EventBase on subscribe.

 

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

InterfaceDescription
IDelegateReferenceRepresents a reference to a Delegate.
IEventAggregatorDefines an interface to get instances of an event type.
IEventSubscriptionDefines 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:

EnumerationDescription
ThreadOptionSpecifies 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]

 

 

Show:
© 2014 Microsoft