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.