Build a Windows 10 universal app
Now you can build one app that runs on all Windows 10 devices and design your pages so they render properly no matter what device is used to view them. Run your app on a Windows 10 phone, a Windows 10 desktop, or Xbox. It’s the same app package! With the introduction of the Windows 10 core and the Universal Windows Platform (UWP), one app package can run across all platforms.
If you want to get a sense of what’s possible, have a look at this UWP guide. Then, go ahead and build your first truly universal Windows app.
First download and install Microsoft Visual Studio. Make sure that the Universal Windows App Development Tools are selected from the optional features list. Without these tools, you won't be able to create your Windows 10 universal apps.
When you develop apps or test an app on a Windows 10 device, you must enable that device for development. You no longer need a developer license with Windows 10. Follow the steps here to enable your device.
When you've done that, notice that only one project appears in Solution Explorer. That's because your app is now truly adaptive and you only need one project to build it.
The project contains one page but you can add others. Each page renders on all devices that your project targets so you don't have to create multiple versions of them. If you want to optimize the experience of a page for a specific device, you most certainly can. We'll discuss that shortly.
The UWP introduces some new controls, such as the RelativePanel and SplitView controls, that adapt their appearance for different types of devices, layouts, and device orientations.
These controls do not yet appear in the Visual Studio toolbox and they won't render properly in the Visual Studio designer, but you can add them to your XAML file manually and then run your app to see how they appear in different types of devices.
You can see how a page renders on different devices without having to run your app on each device. Choose a device from a drop-down list at the top of your designer. The dimensions of the page that appears in your designer change with each selection. You can also choose to view your page in landscape or portrait mode.
To run your app, choose a device target from the drop-down list next to the Local Machine button on the Standard toolbar.
To see how your app appears on a tablet or desktop, run it locally, on a remote machine, or in a simulator. The simulator helps you simulate common touch and rotation events.
To see how your app appears on a different Windows device, choose an emulator or attach a device directly to your computer. To run the app with any of the emulators, you need to install Visual Studio on a physical machine. The physical machine must run Windows 8.1 (x64) Professional edition or higher, and have a processor that supports Client Hyper-V and Second Level Address Translation (SLAT). The emulators cannot run when Visual Studio is installed on a virtual machine.
Most of your code will run on both PCs and mobile devices. Most likely, you won't have to do anything to make that happen. That's because most APIs have been converged into a single Windows Universal SDK. You can find that SDK in your list of project references as shown here.
However, sometimes, you'll have to write code that runs on only on a mobile device. To do that, open the Reference Manager dialog box, and then choose either the Microsoft Desktop Extension SDK for Universal App Platform or the Microsoft Mobile Extension SDK for Universal App Platform.
You'll have to make sure that an API is available on the running device before you use it. For example, this code assigns an event handler to the Windows.Phone.UI.Input.HardwareButtons.BackPressed event. The code compiles because your project contains a reference to the Microsoft Mobile Extension SDK, but what happens when a user runs this app on a PC?
The app would crash because a PC does not have a back button.
To address this issue, use the Windows.Foundation.Metadata.ApiInformation.IsTypePresent method to determine whether a type named Windows.Phone.UI.Input.HardwareButtons is available on the running device. If it is, then the app is running on a mobile device, and the code will execute without crashing the app. The following code does that.
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
Use this pattern throughout your app to add device-specific functionality to your app experience.
Use design states in your XAML to specify how controls should appear based on things like the orientation of the device.
Microsoft Visual Studio 2015 RC does not yet contain features that help you add these design states but you can add them directly to your XAML file, and then run your app to see how they behave.
Sometimes you need more than adaptive controls and design states to achieve a tailored experience. No problem there. You can create device-specific views for your pages. they're not separate pages because they share the same code behind file.
Like device states, Visual Studio 2015 RC does not yet contain features that help you create these but you can add them to your projects manually.
Learn what code changes you need to make to port an existing Windows 8.1 universal app to use the UWP and then run your app on any Windows 10 device.
If you created any Windows 10 universal apps with a Visual Studio 2015 version that was released prior to Visual Studio 2015 RC, you need to retarget your project to the correct SDK for this RC release.
Q: Can I add my Windows 10 universal apps to the Windows store?
A: Not yet.
- UWP guide
- Port an existing Windows 8 universal app
- Windows 10 universal apps
- Build a Windows 8.1 universal app