Mgen spa Engineering 2 tutorial (Part 1): interface components of each platform

Source: Internet
Author: User

Back to the tutorial directory

In the previous section, we learned how to complete the SPA project Interface Generation and hello WorldProgramBut before going over more components of the SPA project, we need to know the interface components of the SPA project for each platform, so that the reader can create a program that can run first, then, we will continue to learn more about the SPA project.

 

Of course, you can download the SPA project.Source codeThe demo programs on each platform are displayed. Here we will talk about the specific interface components of each platform.

Note:

The Display Method of each platform is recommended, but it is not the only display method. "Part 1: Use spavalidationlist to display the interface, verify the controller, and manually verify" in the later part of the tutorial. I will introduce more custom interface display methods.

Directory

    • 1. WPF
    • 2. Windows Phone 8
    • 3. winrt (Windows 8)

 

Returned directory
1. WPF

The type for WPF is defined in the mgen. spa. FX namespace.

In WPF, the SPA project defines a WPF form (window type) named spawindow. You can create a spawindow directly through the spa object, then you can display it in the WPF form operation mode.

Like this:

// Spaobject is the spaobject object variable generated by the spamanager. GetObject method.

New Spawindow(Spaobject).Showdialog ();

 

A window similar to the following is displayed, for example:

 

As you can see, spawindow not only displays the verification interface, but also has the "clear" and "Restore" options in the lower left corner. The restore function restores all values to the value saved last time. The clear function is to reset all values, and the interface after clearing will be as follows:

 

 

Returned directory
2. Windows Phone 8

The Windows Phone 8 type is defined in the mgen. spa. WP namespace.

 

In Windows Phone 8, the auxiliary type of the SPA project interface is spaportraitpage. It inherits from the Microsoft. Phone. Controls. phoneapplicationpage type. Spaportraitpage is defined by the visual studio portrait page template.

Because the navigation operations in Windows Phone 8 are similar to those in Windows Phone 7, they are based on Uris and cannot directly interact with the corresponding page object, therefore, the method for displaying the spaportraitpage page from the spa object is to call the static method navigateto of the spaportraitpage type.

Public Static VoidNavigateto (FrameFrame,SpaobjectSpaobject)

 

The first parameter is the frame object used for navigation, and the second parameter is the spa object.

It is easy to get the root frame in the Windows Phone program. You can use the app. rootframe attribute.

 

The WP8 version of the SPA project displays the spa object as follows:

// Spaobject is the generated spa object variable

Spaportraitpage.Navigateto (App.Rootframe, spaobject );

 

Running effect:

 

What about the four operation buttons in the WPF form?

The confirmation function is the right icon in the toolbar.

The clear and reset operations are displayed after the toolbar is opened, for example:

 

To cancel the call, you can use the backend key of every Windows Phone.

 

Returned directory
3. winrt (Windows 8)

The winrt (Windows 8) type is defined in the mgen. spa. RT namespace.

 

The secondary interface type of the winrt edition of the SPA project is spabasicpage. spabasicpage should be defined by the Basic Page Template of Visual Studio.

In the winrt environment, although Windows Phone and Windows Phone are both page-based navigation environments, the navigation in winrt is type-based, but the good news is that parameters can be passed directly. Therefore, the method for displaying spabasicpage through the spa object is the original winrt navigation call:

// Spaobject is the generated spa object variable

Frame.Navigate (Typeof(Spabasicpage), Spaobject );

 

In the winrt version of the SPA project, the default resource storage type: ultresprovider constructor needs to be initialized using string instead of type. This string parameter is used to create the internal resourceloader type. The resource file in winrt is not a resx file, but a resw file.

 

BelowCodeThis is taken from the interface generation and display in the source code of the winrt demo program of the SPA project.

VaROPT= New Spaobjectoption(

New Validationoption(

Validationtrigger.Propertychanged,

Onloadvalidation.Required,

Objectoption.Edit ),

// Res corresponds to res. resw in the project file

New Defaultresprovider("Res"),

Res.Title );

// The myobject variable is the object to be generated on the interface.

Frame.Navigate (Typeof(Spabasicpage),Spamanager.GetObject (myobject, OPT ));

 

After the generation is correct, the page displays:

 

The "clear" and "Restore" buttons are displayed in the lower left corner. Click OK in the lower right corner. To cancel the operation, click the left arrow button in the upper left corner. This backward mode is defined by the Basic page template in Visual Studio, which is also the recommended page display mode in winrt (Windows 8.

 

Okay, this part is complete. Starting from the next section, we will study the details of the SPA project: the definition of controls.

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.