Prism_ Introduction (1)

Prism 6

Brief introduction

Prism need .Framework4.5, comprising MVVM (Model-View-ViewModel) mode, Navigation, and MEF (Managed Extensibility Framework)

Preparatory

Prism need to learn some of the concepts of WPF, need to understand and be familiar with

  • XAML ( Extensible Markup Language the Application ). Declaratively define and initialize the language of the user interface in WPF applications.
  • Data binding ( the Binding ). This is how WPF UI elements connected to the components and data.
  • Resources ( Resources ). These are the creation and management styles, control templates and data templates in WPF way.
  • Commands ( Commands ). These gestures are user mode and connected to the control input.
  • User controls ( the User Controls ). These provide custom behavior or customize the appearance of components.
  • Dependency property ( the Dependency Properties ). These are the common language runtime extensions (CLR) property system, to enable property is set and monitored to support data binding, routing commands and events.
  • Behavior ( Behaviors ). Behavior is encapsulated interactive features of the object can be easily applied to the user interface controls.

Key concepts

Prism offers you may not be familiar with the functionality and design patterns, especially if you are new to design patterns and composite application development. This section provides a brief overview of the key concepts behind the Prism, and defines some terms that you will use throughout the documentation and code.

  • Modules ( Modules ). Module can be independently developed, tested, and (optional) deployment feature pack. In many cases, modules and maintained by different development teams. Prism Typical applications are built by a plurality of modules. Module can be used to represent a particular service-related functions (e.g., profile management), and packaging to achieve all views, services and data required for the model function. Module can also be used for common applications and services infrastructure or reusable packages in a plurality of applications (e.g., logging and exception management services).
  • Module directory ( Module Cataog ). In composite applications, load modules, and must be discovered at run time by the host application. In Prism, the module directory is used to specify which modules to load, when the load and in what order to load. Module directory by the ModuleManager and ModuleLoader use components, if the module is remote, it is responsible for downloading module, the module assembly is loaded into the application domain, and initialize the module. Prism module allows you to specify the directory in different ways, including using the code programmatically, declaratively in XAML or profile. If desired, you can also implement custom modules directory.
  • Shell ( Shell ). A shell is the host application load module. shell defines the overall layout and structure of the application, but it usually does not know the exact module it hosted. It usually implement common application services and infrastructure, but the function and contents of most applications are implemented in the module. shell also provides a visual element or a top-level window, then host different UI components provided by loaded modules.
  • View ( Views ). UI controls are views, UI specific functions or regions for packaging applications. Used in conjunction with the view mode MVVM, MVVM pattern for providing a point of interest represents the logic and data between the application UI and a clear separation. UI view for enclosing and define user interactions, thus allowing independent of the underlying application functions view updated or replaced. View using data binding model class to interact with the view.
  • View model ( View Models ). Model is a class view showing a state of logical and encapsulated application. They are part of the MVVM pattern. View model encapsulates most of the functionality of the application. View model custom attributes, commands and events, view controls can be data-bound.
  • Models ( Models ). Model class encapsulates application data and business logic. They are used as part of MVVM pattern. Model encapsulates data and any associated validation and business rules to ensure consistency and data integrity.
  • Commands ( Commands ). Command used to encapsulate application functionality, allowing independent application UI definitions and test them. They can be defined as the command or command methods in view of the model. Prism offers DelegateCommand classes and CompositeCommand class. The latter is used to indicate a set of command calls together.
  • Region ( Regions ). Region is a UI of the application (in the shell or view) logic defined placeholders, wherein the display view. Layout area allows updating the application UI without changing the application logic. Many commonly used as a control area, to allow the view is automatically displayed in the control, for example the ContentControl , the ItemsControl , the ListBox or the TabControl . It may be displayed in the view area programmatically or automatically. Prism also provides support for the implementation of area navigation. Region can RegionManager components by other components positioned for this component RegionAdapter and RegionBehavior assembly to coordinate the view displayed in a specific area.
  • Navigation ( Navigation ). Navigation application is defined as a process by which changes to interact with the application or the application state to change its UI. Prism supports two navigation styles: based navigation state, the state in which the existing view is updated to enable simple navigation scene; and switch navigation views, which create a new view and replace the old view in the UI of the application. Switch the view navigation based uniform resource identifier (URI) of the navigation mechanism combined with Prism area to allow for flexible navigation solution.
  • Event polymerization ( EventAggregator ). Composite application components typically need to communicate in other ways with components and services in the loosely coupled applications. To support this, Prism provides EventAggregator component that implements pub-sub event mechanism, allowing the assembly of published events and other components to subscribe to these events without the need to refer to another event. The EventAggregator often used to define the allowed member in different modules communicate with each other.
  • Dependency injection vessel ( the Dependency Injection Container ). Prism entire dependency injection (DI) mode to allow the management of dependencies between components. Dependency injection assembly allows dependencies at runtime, and it supports scalability and testability. Prism Unity or intended for use with MEF, or by ServiceLocator with any other dependency injection containers.
  • Services ( Services ). UI is a non-service component package related functions, such as logging, and data access exception management. Service can be defined by the application can also be defined within the module. Services are typically register dependency injection vessel, so that they can be positioned as desired configuration or by other components depending on their use.
  • The controller ( the Controllers ). The controller is initialized and the class is configured to display the view region to be coordinated in the application for the UI. Indicating controller package which represents a logical view be displayed. The controller will switch the view navigation using Prism mechanism that provides scalable URI-based navigation mechanism to coordinate the construction and placement of the view region. Application Controller schema defines an abstract mapped to this responsibility.
  • Boot program ( Bootstrapper ). The boot program component application using various prism assembly and service initialization. It is used to initialize dependency injection vessel, is registered to any application-level components and services. It is also used to configure and initialize the module directory and shell of view and the view model or presenter.

Prism design allows you can use any of the aforementioned features and design patterns alone may be used together according to your requirements and application scenarios. You can use any combination of the MVVM pattern, modular, regional, command, or events without using all of these modes. Of course, if you want to take full advantage of the benefits of separation of concerns and loose coupling provided, you would normally use Prism's many features and design patterns combined with each other. The following figure shows a typical Prism application architecture, and shows how all the various functions Prism work together in a composite multi-module applications.

Typical library using Prism composite application architecture

Most Prism application consists of a shell composed of application, the application definition display for shared services area and can be top-level view of the load module to access. shell define a suitable directory to specify which modules (if applicable) to load at startup. Also defines a dependency injection container allows assembly dependencies at runtime. When the application starts, Bootstrapper in a vessel registered shared services and components.

Each module encapsulates the functionality of the overall application, and the use of a separate schematic (e.g., the MVVM) define the view, the view model, the model and service components. Loading module, the module defined view is displayed in the area defined by the shell. After initialization is complete, the user can then use the navigation based on the status or change the view navigation within the application, visible to the new view within the reconciliation application area update or display.

Guess you like

Origin www.cnblogs.com/lovexinyi/p/11068905.html