As developers prepare for the coming wave of Universal Windows Apps across Windows 10 devices, Microsoft is highlighting new Visual Studio 2015 features like adaptive code.
In a session at the Microsoft Ignite conference in Chicago, Microsoft senior program manager and Windows XAML team member Harikrishna Menon ran through the process of leveraging the code tools, APIs and SDKs within Visual Studio 2015 to create Universal Windows Apps on Windows 10 devices.
He began by reiterating that Universal Windows Apps for Windows 10 for desktop, mobile, Xbox, HoloLens, Surface devices and Internet of Things devices all run on the same set of core APIs.
“For the first time ever, Microsoft has a core set of APIs that work everywhere,” said Menon. “Every device family running on Windows 10 will have a core set of APIs. You can build a single application package with binary compatibility.”
In the arsenal of Universal Windows App development tools included within Visual Studio 2015, Menon drew particular attention to a new process called Adaptive Code. Allowing developers to write code across different Windows versions and devices, the process checks for the presence of a specific API before invoking it. He said putting universal app code through these API checks would prevent it from failing.
Used in tandem with a new set of APIs called apiInformation, the adaptive code process can check if a property, event or type is available on a given device before calling them.
“You’re never calling APIs on devices that don’t have them,” said Menon. “The same code can work well in both Windows on mobile as well as on a desktop local machine. This is how you can adapt your code going forward.”
Two other new Visual Studio 2015 features Menon highlighted were adaptive triggers and tailored views. Adaptive triggers recognize the screen properties of a given Windows 10 device and adapt the app’s controls and panels automatically to fit it. Tailored views, on the other hand, break out multiple XAML files for different device families. The device’s files all share the same code, though, so with tailored views the app will load the right XAML file based on the device family.
There’s also a new Windows Universal node in the project dialog, which includes a blank template, class library and Windows runtime component to share code in different languages, from C++ to JavaScript and C#.
When creating a new universal Windows 10 app, Visual Studio 2015 provides a simulator, local machine, mobile emulators, a unit-testing template, and a XAML Designer with IntelliSense for every new template. In the adaptive application package, Menon said developers should pay particular attention to defining the minimum and maximum supported versions of their app.
“The best possible thing you can always do when building an application is keep the minimum version as low as possible and the max version as high as possible, guaranteeing you can be installed on every Windows 10 device out there,” he said.
For third-party extensions and controls, Menon pointed to a new Windows Device Family of extension SDKs. Developer and third-party vendors can add a small amount of reference code and use the Windows 10 SDK manifests to integrate their controls into universal apps from within VS 2015. Along with a feature he referred to as extensible “Behaviors,” Menon said developers could add interactivity to applications with just a few lines of markup.
Other notes during the session about Universal Windows App features in VS 2015 included:
- NuGet support: Universal app support is already available for Windows 8.1 NuGet packages, with Windows Phone 8.1 NuGet packages to be available upon the VS 2015 release to manufacturer.
- Azure App Insights: An integrated VS 2015 service available in the Microsoft Azure portal that allows developers to monitor Windows 10 universal app performance and usage statistics in real time without writing additional code.
- .NET Native: A new feature to compile managed applications into native code to significantly improve app performance. The feature gives C# code similar startup and memory to manage applications by using the .NET Native tool chain.
For more information on all the APIs and SDKs within Visual Studio 2015 for Windows 10 universal app development, Menon suggested developers visit the Universal Windows app samples repository on GitHub.