Windows Phone 8 Beginner's Tutorial (12) Improving the view model and sample data

Source: Internet
Author: User

Original address: http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners/ Part-12-improving-the-view-model-and-sample-data

Series Address:http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners

Source code: HTTP://AKA.MS/ABSBEGINNERDEVWP8
PDF version:http://aka.ms/absbeginnerdevwp8pdf

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

We've done our basic work, and next we'll focus on the core of the application: the data model. This requires that we transform the entity model of the previous lesson into a viable data model that can represent the hierarchical structure between data and data.

Here are our plans for this lesson:

We will briefly analyze our requirements (the entity model is all we have today) and quickly map out the data model that will be implemented in the application.

We will implement the data model in code.

We will create the data in an XML file to display it in the mainpage XAML designer at design time.

Modifies the MainPage.xaml binding expression to point to instances and properties of classes in the data model.

1. Analyze the entity model and design the data model

After viewing the entity model and thinking about how to optimally delegate tasks to different classes, I designed a basic class model with the data structure of the application class model as follows:

The Soundmodel class contains references to groups of five sounds in your application. Please note that these properties are soundgroup types.

The Soundgroup class represents the view or type that I referred to earlier. I've been looking for a correct term to describe it, but in essence it's a grouping rather than a view or type. (The View only indicates the visual effects of the tiles used to display the sound, and the type is.) NET has a special connotation) Soundgroup has a title (it is used in the MainPage.xaml pivot control as the PivotItem caption) and a sounddata generic collection.

The Sounddata class represents the sound itself. Each Sounddata instance will contain a title, and clicking the title will play the sound associated with Sounddata, which is stored in the Sounddata filepath attribute.

Then we will implement the function in the diagram through the code and there will be some additions in the process of implementation.

2. Create a new data model class for your application

Based on our plans and data model diagrams, we will implement this new data model.

Right-click the ViewModels folder and choose Add | new item:

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.