Your First UWP Application
Your First UWP Application
Your First UWP Application
Microsoft’s Universal Windows Platform is a case in point. A refactoring of the familiar Win32
and .Net APIs, it’s intended to be the future of Windows application development. Alignment
with the .Net Standard libraries makes it possible to use a single Visual Studio project to support
both Windows desktop and cross-platform Xamarin applications, by keeping user interface code
and core logic separate.
[ Review: Visual Studio 2017 is the best ever. • What’s new in Microsoft’s Visual Studio
2017. | Cut to the key news and issues in cutting-edge enterprise technology with
the InfoWorld Daily newsletter. ]
But like all new platforms, there’s resistance to switching code to something new, especially
when it’s focused on newer platforms. When old code runs on new platforms, there’s no
incentive to begin a migration. So how can you start enterprise UWP development when Win32
is still a valid option?
Microsoft has made the Windows Template Studio an open source project, hosted and
downloaded from GitHub. Installed as a Visual Studio extension, it adds a new option to Visual
Studio’s C# New Project dialog. Once you’ve chosen to build an app using Template Studio,
you’re presented with a series of options that guide you through choosing an application layout,
followed by the application framework you intend to use.
The available layouts are simple: a basic navigation pane with a hamburger menu selection, a
pivot view controlled by tabs, and a blank canvas. There’s a lot to be said for a relatively sparse
selection of layouts, with the two main options covering most common use cases, and the third
giving you a freeform layout ready for whatever you want to build.
[ Learn Java from beginning concepts to advanced design patterns in this comprehensive
12-part course! ]
Two of the MVVM options come from third parties: MVVM Light and Caliburn.Micro. Like
Microsoft’s own open source software, both use the MIT license, so there shouldn’t be any
problem using them in your code.
Once you’ve chosen your layout and framework, you can start to flesh out the skeleton of your
app with pages. Like most modern applications, the Windows Template Studio builds on the
page model used by most web apps. It’s an approach that makes it easy to go from C# app
running on a PC to a Xamarin app on a mobile device to a web application, all running from the
same back end.
You’re not limited to a single page; you can use Windows Template Studio to add multiple pages
to your app, with support for familiar application elements, including grid and master/detail
pages, as well as charts and maps. Currently, 11 page types are available, with more added with
each release. Some page types access specific UWP features, such as device camera, but most
give you a basic page layout with support for a specific application feature. The Chart and Grid
options use Telerik’s free UWP controls (which are also open source, under an Apache license),
giving you a feel for how to use third-party UWP components in your code.
Perhaps the most important aspects of its UWP feature support are how it simplifies adding key
application life cycle elements. UWP builds on the WinRT model introduced with Windows 8,
which added features to enable apps to roam settings through the cloud, as well as suspending
and resuming rather than shutting down. Windows Template Studio adds code to support these
features, as well as support the use of in-process background processes, which can work with
remote services even while an application is running in the background. While a background task
runs, data updates and users see any changes—without you having to write a separate
background service to support your code.
Although Windows Template Studio simplifies the building of UWP applications, it’s not a
replacement for the now-discontinued Visual Studio LightSwitch LOB application builder. Tools
like LightSwitch and its near codeless kin PowerApps are a modern take on the 4GL epitomized
by languages like Forte. Windows Template Studio isn’t a tool for building form-based
applications with minimal code; it’s more a way of quickly putting together the framework that
can host your business logic in a UWP app.
If you’re ready to go beyond simple application builders, Windows Template Studio is well
worth investigating. You can do a lot more with a foundation like this, because the code it
produces will support not just your first UWP app but also future releases as you add new
features.