Use Windows 8 to develop the first Windows App Store application

Source: Internet
Author: User
Use Windows 8 to develop the first Windows App Store application

This section uses a simple windows App Store application as the first example to illustrate the basic development steps of Windows App Store applications. Although this example is very simple, it can help readers establish a preliminary understanding of application development in the Windows App Store and prepare for the knowledge to be learned.

1 Development Technology Selection

Currently, Windows App Store applications can be developed using. Net (Visual C #, Visual Basic), JavaScript, and Visual C ++. Where. NET technology is currently the most popular development technology, prior to this Silverlight, WPF and Windows Phone are on. NET development technology to provide the main support, that is, the previous. NET technology can be quickly transferred to the application development of the Windows app store based on the original knowledge. Javascript is the "flag" of Web Front-end development ", all developers engaged in Web application development are familiar with JavaScript, so Javascript development technology is suitable for developers who are familiar with web design before. Visual
C ++ has strong advantages in DirectX programming and hardware device programming. Of course, it is also suitable for developers who are familiar with Visual C ++ development technology.

Although these development methods have their own advantages and disadvantages, no matter which development technology is used, it can ultimately meet the application development needs. The advantage of supporting multiple development technologies for Windows App Store applications is that more developers can join in and quickly develop Windows App Store applications using the development technology they are familiar.

Considering. NET technology is widely used and the efficiency of development, this book will focus on. the most widely used XAML + Visual C # technology combination in net development technology is explained, at the end of this book, I will introduce the two development methods of Windows App Store applications: JavaScript and Visual C ++.

2. Create a Windows App Store application

Start Visual Studio 2012 integrated development tool, open the "file" menu, select the "new project" menu item, and the "new project" window is displayed, as shown in 2-22. In the Visual C # template category on the left of the new project window, select windows App Store and select "Blank application (XAML)" from the Project template list in the middle of the window) "Project template, enter the project name" firstapp "in the" name "text box below the window, and click" Browse "next to the" location "text box to select a storage path for the project, after selecting the path, click "OK" in the lower-right corner of the "new project" window to complete project creation.

Figure 2-22 create a Windows App Store Project

After the project is created, double-click the "solution Resource Manager" window to open the default mainpage created by the Project template. the default homepage of the application, including the XAML code used to describe the interface design. Visual Studio 2012 automatically uses the designer to open this file. After the designer is opened, the control in the toolbox will be activated, in this way, you can select the required controls from the toolbox and drag them to the designer to design the application interface.

Drag a textblock control from the toolbox to the designer, and set its name to "mesgtextblock" in the attribute panel. The font size attribute is 72, drag it to the center of the screen with the mouse.

Drag a button control from the toolbox to the designer and set it to "showtextbutton" in the property panel. The font size is 36, the height is 100, and the width is 200, set the content to "show text", click the "lightning" icon in the upper-right corner of the property panel, and switch to the event panel. Find the click event in the event panel, double-click the text box next to the event, and add the event processing method "showtextbutton_click" for the Click Event of the button, finally, drag it to the bottom of the textblock control in the designer.

After completing the preceding operations, the code in the grid element of the mainpage. XAML file is as follows:

<Textblock X: Name = "mesgtextblock" margin = "380,274, 0, 0 "horizontalalignment =" Left "fontsize =" 72 "textwrapping =" Wrap "text =" textblock "verticalignment =" TOP "/> <button X: name = "showtextbutton" Click = "showtextbutton_click" margin = "592,388," fontsize = "36"
Height = "100" width = "200" content = "show text" horizontalalignment = "Left" verticalignment = "TOP"/>

After the interface design on the home page is completed, the following code will be written for the click event handling method of the button control in the interface. In Solution Explorer, double-click to open the mainpage of the project. XAML. CS file, which is the mainpage on the home page. the background function code file corresponding to the XAML. Visual Studio 2012 automatically loads the file using the code editor window. Find the event handling method showtextbutton_click added for the button in the file code, and add a line to it to display "Hello, Windows 8!" In the textblock control on the interface !" Text code.

The showtextbutton_click method code is as follows:

// How to handle the event by clicking the showtextbutton button
Private void showtextbutton_click (Object sender, routedeventargs E)
{
// Assign values to text blocks
Mesgtextblock. Text = "Hello, Windows 8! ";
}

So far, we have completed the design and development of the first Windows application store application. Next, let's take a look at the operation and debugging of the application.

3 Local Computer debugging

In Visual Studio 2012, there are two common debugging and running methods for Windows application store applications: one is to directly upgrade the test run on a local computer, and the other is to run the program using a simulator. By default, Visual Studio 2012 runs debugging on a local computer. Under the Debug menu, select the start debugging menu, or press the F5 key on the keyboard, you can start running and debug the project.

After the program starts, click the "show text" button on the application interface. You can see that "Hello, Windows 8!" is displayed at the text block position above the button !" This text is shown in 2-23.

Figure 2-23 upgrade the trial run project directly on the Local Computer

4 simulator debugging

Because Windows App Store applications are mainly designed for touch-able flat devices, for developers who do not have flat devices, the simulator can be used to simulate the Running Effect of applications on real tablet devices.

2-24, click the Small Arrow next to the start debugging button in the toolbar above Visual Studio 2012, expand the "target device" list, and select the "Simulator" list item in the list, you can set the target device of the project as a simulator.

Figure 2-24 change the debugging option to "Simulator"

After debugging is started, you can see the same running effect as that of the Local Computer in the simulator, as shown in Figure 2-25.

The simulator takes a long start time when it is started for the first time. The time required varies depending on the computer configuration. After the first startup, You can temporarily disable the simulator so that you do not need to restart the simulator when you debug the program again to deploy the application to the simulator for running.

Figure 2-25 debug and run a project using a simulator

From Figure 2-25, we can see that there are some operable button options on the right side of the simulator. These options can help us debug the project. The common options are as follows:

  • The mouse mode allows you to interact with each other, including clicking, double-clicking, and dragging.
  • In Touch simulation mode, you can use the mouse to simulate the Touch gestures of your fingers, including clicking, dragging, and sliding.
  • Zoom-in/zoom-In Touch simulation mode. You can use the mouse to simulate the zoom-in and zoom-in gestures of two fingers.
  • Rotating touch simulation mode, you can use the mouse to simulate the rotation gesture of two fingers.
  • The simulator rotates 90 degrees clockwise.
  • The simulator rotates 90 degrees counterclockwise.
  • Changes the screen size and resolution of the simulator. You can set the location to simulate the current location information of the device.
  • Capture: the application in the simulator can be captured and placed in the clipboard.
  • You can set the location, method, and other operations.

In addition, there is a button at the bottom of the simulator, which works the same as the hardware button on the real device, and can implement fast switching between the current operation page and the Start Screen. It should be noted that the simulator also supports animation switching effects on real devices. Although the simulator cannot Debug programs that require real-time navigation, instant camera, instant camera, and other real hardware support, however, it can also be done through simulation, which will be mentioned in later chapters.

It should be noted that, although the simulator can simulate and debug windows App Store applications, it still cannot completely achieve the experience and Effect of real devices, in particular, the current version of the simulator has been tested and found that some sensors cannot be simulated. Therefore, for professional developers, it is best to use hardware devices to perform a comprehensive test of the application before the application is released, to ensure that the application can achieve the expected results. The next section describes how to deploy an application to a real device for debugging and running using remote debugging.

--------------------------------------------------------------

This article is excerpted from "Windows 8 Application Development authoritative guide" by Feng ruitao & Yan.

The technical content of the Windows 8 Application Development authoritative guide covers Visual C #, JavaScript, and Visual C ++ development languages to meet the needs of different audiences. In order to facilitate the readers to learn, the book focuses on the technology and provides a complete Example demonstration, so that the readers can quickly apply the knowledge they have learned to practical development, finally, three comprehensive cases are carefully designed for different development languages, which is highly operable. The book is divided into 21 chapters: 1st ~ Chapter 2 first introduces the features of the Windows 8 system, the design style and ideas of the Windows App Store application, and the features of the Windows App Store application, then, the development tools required for developing applications in the Windows App Store and their usage methods are described in detail. Then, the developer account registration, Development Environment setup, remote debugging, and application release are introduced; chapter 2 describes in detail the XAML syntax basics for Windows App Store application development. Chapter 2 ~ Chapter 18 describes how to use visual
C # related technologies for developing Windows App Store applications, including application controls, interface layout and navigation, data binding, push notifications, graphics and painter, multimedia, animation effects, multithreading and background tasks, sensors, file and data storage, network communication, and life periodic management, map applications, external devices, and globalization; 19th ~ Chapter 20 describes the important technologies used in the development of Windows App Store applications in JavaScript and Visual C ++; chapter 2 combines the technical knowledge described in the previous chapter to fully implement a real windows App Store application case.

Douban Web site: http://book.douban.com/subject/21327962/

Sample chapter trial: http://vdisk.weibo.com/s/paCcV/1359689652

Author profile:

Feng ruitao has been engaged in software development and project management for eight years in Beijing. He is very interested in development technologies related to Windows systems, especially for mobile internet and server-related technologies, and fascinated by Microsoft's powerful and easy-to-use development tools and server software, I like to share and exchange technical experiences with my community partners in my spare time. Weibo: @ Feng ruitao terryfeng, Twitter: @ fengruitao

Yan, a software development engineer who specializes in mobile internet and cloud computing, has in-depth research on the interface design and automated testing of mobile terminal device applications, and is familiar with Windows Phone, Android, and iOS platform application development technologies. Weibo: @ Yan Yanyan, Twitter: @ finehappy

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.