Blog Park Client (Universal App) Development essay-Hello, Universal

Source: Internet
Author: User

After mobile and cloud became Microsoft's theme, the Windows Phone 8.1 phone and Windows 8.1 Tablet also matured, attracting more and more developers. To enable developers to efficiently develop a cross-cell phone and tablet application, Microsoft has introduced the concept of the universal application.

Today we want to share with you how to start developing a Universal app across Windows 8.1 and Windows Phone 8.1 in the C # and XAML languages.

Get ready

The first hardware aspect of our computer is to support the Hyper-V feature or have a phone that runs the Windows Phone 8.1 operating system.

The software requires the installation of Windows 8.1 and Visual Studio Update 2 and above on your computer. The free Microsoft Visual Studio Express for Windows with Update 4 is available at Http://www.visualstudio.com/zh-cn/downloads#d-exp Ress-windows-8 can find.

When you start Visual Studio 2013, you will need to register a Microsoft account for your first launch, and you can log in directly if you have one.

Hello Universal

Now we can create the Windows Universal App.

Click on new item on the Start screen or click on the new project, file, on the menu bar

Select a blank application, universal application,->visual c#-> store app installed

Select Save folder and enter the project name, such as "My Universal"

Click OK.

Well, Visual Studio has automatically created a universal solution for us:

In Solution Explorer you can see that our Universal solution contains 3 projects, my universal.windows,my universal.windowsphone,my universal.shared.

They correspond to Windows apps, Windows Phone apps, shared resources, respectively.

Start

Now that we haven't written a single line of code, our app is ready to run.

Take a look at our Windows app First:

Click the Debug button

After a period of compilation, our Windows app starts. Of course there is no content, only one title is here. Now move the mouse to the upper right corner and close it first. (It may be possible to return to visual Studio to see if it is still in the debug state and need to manually stop Debug.) )

Next look at our Windows Phone app.

Click the small down arrow next to the Debug button.

Select Startup Project, my universal. WindowsPhone (Windows Phone 8.1)

The Debug button has changed, the text becomes a device, and if your computer supports Hyper-V, you will also see a series of Windows emulators (Emulator).

Let's take a look at support for Hyper-V. We select a simulator and click the Debug button. Visual Studio launches the corresponding emulator to deploy and launch our Windows Phone app on top of it. (Starting the emulator will be slow, we can end the debug without shutting down the emulator, but instead click the Stop Debug button in Visual Studio so the emulator won't close)

Of course, our Windows Phone is nothing at the moment, and there's only one line of title here.

Here's a look at what happens if our computer doesn't support Hyper-V:

Usually our daily use of Windows Phone 8.1 phone is not ready for development, we have to register it as a developer phone.

We need to connect our Windows Phone 8.1 phone to the computer via a USB cable and unlock the lock screen.

Then open windows Phone Developer Registration 8.1 on the Start screen.

The program detects our Windows Phone 8.1 phone and clicks Register and enters our Microsoft account to register it as a developer phone.

This allows you to select device on the Debug button and debug our Windows Phone 8.1 app using your phone instead of the simulator.

What is Universal?

You may notice that our Debug button can choose the Startup project only my Universal.windows,my universal.windowsphone two, then my universal.shared this project is what to do?

In fact, this project is the focus of universal apps where we can share code for Windows apps and Windows Phone apps.

Our apps can be run on windows and Windows Phones, and their interfaces are very different. But the logic behind it works almost the same way. In the past development methods, we may have to write two sets of background code, respectively, to maintain them. There's something wrong, you need to change it, and you have to check the code on the other side. But when we create the universal application, this situation is greatly reduced. Just modify the same one. Share projects, you can work with Windows and Windows Phone apps at the same time. There is a difference between them, we can also use conditional compilation to distinguish.

For example, we can open the project my universal. App.xaml.cs file in shared:

You can see the options available in the upper-left corner of the editing area. Windows and. Windows phones, are currently selected. Windows. In the code area, the code that is sandwiched between the # if Windows_phone_app ... #endif is in a gray state. This piece of code is unique to Windows Phone. Now the gray is shown because we have selected in the upper left corner. Windows project, it is not working.

Overall, the universal application is through the. Share project to share code across different platforms, reducing cross-platform maintenance and enabling efficient development.

Summary

Isn't it very convenient? Create, 2 apps at a time. This is the charm of universal. Next we will share with you how to extend this simple application into a fully functional cnblogs reader. We welcome your continued attention.

Blog Park Client (Universal App) Development essay-Hello, Universal

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.