Using Visual Studio to build a common XAML application (Windows Phone and Windows Universal programs)

Source: Internet
Author: User

At the build conference, we released a new version---the Windows Phone 8.1, Windows 8.1 platform. As a developer, this means that you can now build generic programs for XAML and HTML, and make them run on phones and tablets by sharing a lot of code and content. To make the build generic program available, we have added many new features in Visual Studio as part of the Visual Studio Update 2 RC.

You have two ways to learn more about these features. One way to do this is through this blog. Another way is to watch my build talk video, which covers all the information you will see in more detail:

There is no right or wrong way, so choosing a video or blog depends on your time. No more delays, let's hurry up and see the Universal app!

Create a common Application

To help you build common programs with C #, C + + and JS, we have created new project templates that contain basic structure and background configuration, allowing you to share code and content:

If you already have an existing Windows 8.1 application, you can use the Add Windows Phone 8.1 command to add a new Windows Phone 8.1 project and a shared project in the solution. And if you already have a Windows Phone 8.1 app and want to add support for Windows 8.1, you can also use similar options.

Structure of a generic application

A generic application is a collection of three items--windows Store projects, Windows Phone projects, and Shared Items--included in the solution folder, is optional. Windows Store and Windows Phone are platform projects and are responsible for creating application packages (. appx) for their respective platforms. These projects contain the assets of a specific target platform.

Shared items contain assets that are shared between Windows Store and Windows Phone projects. The project types supported by shared projects (. cs, XAML,. xml,. png,. RESW, and so on) are the same as platform projects. The shared projects themselves do not have binary outputs, but their content is imported by the Platform project and used as part of the Windows Store and Windows Phone application package (. appx) build process.

Writing code in a shared project

When developing a generic application, you are primarily running code written on these two platforms. If needed, you can also write platform-specific code using #if and #endif directives in shared projects. By default, we predefine the following conditional compilation constants, which you can use to write specific platform code.

C#

Windows_app

Windows_phone_app

C + +

Winapi_family_pc_app

Winapi_family_phone_app

Context switches in the editor

When you write code in a shared project, you can use the project context switcher in the navigation bar to select the target you are working on, and then drive the IntelliSense experience for the platform in the Code Editor.

To switch the startup project using the Debug target drop-down list

We've also added the ability to quickly switch startup items in the Debug target drop-down list, and you can list all possible projects in the solution that you might want to deploy to devices or emulators/simulations.

Share code between common applications

You can use a class library to share your code between different generic applications. For C # and Visual Basic, we improved our existing Portable class library (PCLS), which enabled us to support Windows Runtime and XAML on the specified Windows 8.1 and Windows Phone 8.1 platforms. Read this blog for more detailed information on PCL improvements.

For C + +, you can use the New Class Library project template under universal application to share your code with shared items between Windows 8.1 and the Windows Phone 8.1 class library.

I hope you feel this is useful for an overview of generic applications that build XAML. If you have any questions or comments, please feel free to contact us by thread or through the forum or UserVoice. Stay tuned for another blog that explains the functionality of the new XAML tools we added in Visual Studio to support Windows Phone 8.1 applications.

Using Visual Studio to build a common XAML application (Windows Phone and Windows Universal programs)

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.