Caliburn Micro Framework Windows Phone 8 use Research (iii) magical tombstone treatment

Source: Internet
Author: User

Background

Tombstone in the development process of Windows Phone 8 really makes us love and hate, it can make the program seems to be running. But dealing with tombstones is a very troublesome thing, the traditional way we need to be in the program Deactived event triggered, the need to save the state to put in, and then the user back to load out. And if our program uses the MVVM architecture, the situation will be more complex and complex. Believe that everyone has experience. Without saying much, let's continue to look at the magical tombstone in the CM framework.

Start with simple code:

On the test page, we add a textbox named Name:

Then add the Name property to the ViewModel to implement the INPC interface.

Only so, when the user enters the message into the textbox, the tombstone returns, and the input in the textbox remains the tombstone's content. Still analyze the problem from the question:

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

1. What is Storagehandler for?

This class is the class that handles tombstones, and when the program starts, it reflects all classes that inherit this class, then processes it, and when the program deactived, it automatically stores the configured properties in state, and when the program starts again, it reverts back to the ViewModel

2, property function and Inphonestate function?

These two functions are used to configure which of the corresponding attributes in the ViewModel are placed where, for example, the Name property is stored in the state in the preceding code

3, just need this code?

We're going to call registerphoneservices in Bootstrapper's configure, which registers the class for tombstone processing for our operations.

Summarize

CM is a really worthy of in-depth study of a class library, the author of the idea of solving problems is worth our learning, and many methods of implementation is also a good place for us to learn grammar.

And in terms of use, CM for WP system provides additional support, so that it becomes WP APP MVVM architecture of the choice.

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.