Windows Phone mango programming practices-third-party mvvm framework

Source: Internet
Author: User
ArticleDirectory
    • Bind datacontext in Blend

Windows Phone mango programming practices

Windows Phone mango Programming Practice

Objective: To develop a practical manual for Windows Phone

Mvvm design mode Overview

The Model-View-viewmodel (mvvm) design mode clearly separates the business logic and presentation layer of the user interface (UI. Mvvm enables user interface designers to focus on interface design, while developers focus onCodeBusiness logic, and make it easier for developers and user interface designers to cooperate in the software production process.

In the mvvm design mode, the applicationProgramThe user interface, underlying representation, and business logic are divided into three different categories: View, viewmode, and model ). The mvvm design mode is like the terrain in Sun Tzu's Art of War: "The terrain is accessible, accessible, supported, risky, and distant. "The terrain is also assisted by soldiers; mvvm is helpful for application testing, maintenance, and upgrade. Familiar with mvvm classes and their interaction is "Never be noticed ". Therefore, the saying goes: "Whoever knows this and uses it will win, and those who do not know this will lose ".

    • View-encapsulates the user interface and UI logic view model;
    • View model viewmodel-encapsulation indicates the logic and status;
    • Model-encapsulates the business logic and data of the application;

Demonstrate mvvm classes and their interactions.

 

Figure 14-1 mvvm classes and their interaction

Third-party mvvm framework

There are many good third-party mvvm frameworks on www.codeplex.com for our reference, among them, mvvm light toolkit, Ultra Light mvvm for Windows Phone, and simple mvvm toolkit are all suitable for the development of Windows Phone.

Mvvm light Toolkit

Mvvm light toolkit is a set of components that help people use mvvm Design Patterns in Silverlight and WPF. It is a lightweight and pragmatic framework that only contains the necessary components.

: Http://mvvmlight.codeplex.com /.

Bind datacontext in XAML

Two additional classes are added to the viewmodel Folder: viewmodellocator. CS and mainviewmodel. CS. Viewmodellocator declares the datacontext binding that can be used as the source in APP. XAML; mainviewmodel has also been added to the project viewmodellocator as a public attribute.

Note:

If you do not need to use mainviewmodel in the project, you can delete this class.

To use mainviewmodel as the datacontext of mainpage. XAML, add the following code in the start tag of mainpage. XAML:

Datacontext = "{binding main, source = {staticresource locator }}"

Bind datacontext in Blend

You can also use the following steps to bind datacontext in expression blend.

    • Open the windows phone project in expression blend;
    • Compile the application;
    • Open mainpage. XAML;
    • Select usercontrol in objects and Timeline panel;
    • On the Properties panel, select the datacontext property (in the common properties Section) and select data binding from the drop-down menu of the advanced property. Data Binding of blend.


Figure 14-2 Data Binding of Blend

More information about the mvvm light Toolkit can be found on http://www.galasoft.ch/mvvm/getstartedFor more information about mvvm light toolkit, log onHttp://www.galasoft.ch/mvvm/getstarted
..

Ultra Light mvvm for Windows Phone 7

Ultra Light mvvm is a lightweight mvvm Silverlight application that supports tombstoning for Windows Phone ). Ultra Light mvvm supports the features of Windows Phone:

    • Command
    • Command button (using parameters) Binding
    • Allows you to bind commands to the application bar.
    • Dialog box, notification and confirmation
    • Location service
    • User-friendly visual mode during design
    • Tombstone friendly view model with tombstone Event Control hooks
    • Navigation support for decoupling from view Models
    • Support for visual States decoupled from view Models
    • Block the backkey in the view Model
    • Allocator help for user interface thread access

: Http://ultralightmvvm.codeplex.com /.

Simple mvvm Toolkit

Simple mvvm toolkit makes it easier to develop applications with the mvvm design mode Widnows phone. It provides a simple framework and toolset for applications based on the mvvm design mode. Simple mvvm toolkit features simplicity, but it contains everything required for applications that execute the mvvm design pattern.

: Http://simplemvvmtoolkit.codeplex.com /.

Comparison results of simple mvvm toolkit and mvvm light toolkit from Tony Sneed's blog.


Figure 14-3Comparison Between Simple mvvm toolkit and mvvm light Toolkit

Simple mvvm toolkit the mvvm application simple mvvm toolkit after installation.

Figure 14-4 simple mvvm Toolkit

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.