Use of Caliburn micro framework WP8 (iii) tombstone Processing

Source: Internet
Author: User

Background

In the Windows Phone 8 development process, tombstone's processing really makes us love and hate, and it can makeProgramIt seems to be running all the time. However, it is very troublesome to process the tombstone. In the traditional method, we need to put the state to be saved after the deactived event of the program is triggered, and then load the state after the user returns. However, if our program adopts the mvvm architecture, the situation will be more complicated. I believe everyone will understand the complexity. Let's continue to look at the Magic tombstone processing in the CM framework.

 
 

From simpleCodeStart:

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


 
 

Then add the name attribute to viewmodel to implement the INPC interface.


 
 

In this case, when the user enters the information in the textbox and the tombstone returns, the input in the textbox is still the content in front of the tombstone. Analyze the problem from the problem:

1. What is storagehandler used?

This class is the class for processing the tombstone. CM will reflect all classes that inherit this class when the program starts, and then process it. After the program deactived, the configuration property is automatically saved to the state. When the program starts again, the property is restored to the viewmodel.

2. What are the property and inphonestate functions?

These two functions are used to configure the location of the corresponding attribute in viewmodel. For example, in the code above, the name attribute is put into the state for saving.

3. Do I only need these codes?


We need to call registerphoneservices In the configure of bootstrapper. This function will register the class for tombstone processing for our operations.

 
 

Summary

CM is indeed a class library worthy of in-depth research. The author's idea of solving the problem is worth learning, and many implementation methods are also a good place for us to learn the syntax.

In terms of usage, CM provides additional support for the WP system, making it the best choice for the WP app mvvm architecture.

 
 

QQ chat group: 182659848

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.