Tips, tricks, and guides for developing on modern Windows platforms
I keep seeing (and having) the same problems crop up for people getting started with Universal Windows Platform (UWP) app development, so what follows is a FAQ-like post of quick answers.
A UWP app has a minimum supported version listed in its project file. When building on Windows 10 RTM, that minimum version is set to 10240 – the Windows 10 RTM build number. But for the time being our Windows 10 phones are running pre-release builds, such as build 10166. You need to tweak your app project so it thinks it’s OK to run on your phone’s earlier version of Windows 10.
2) Open the project file for editing by right-clicking it and selecting the Edit option:
4) Reload your project by right-clicking it and selecting Reload Project.
Windows 10 defaults to white title bars for all apps (which looks terrible in my opinion), but it’s trivial to change it for your app. I created the following method, which I put in App.xaml.cs to change the title bar as soon as the app launches:
private void SetTitleBar()
var appView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
var titleBar = appView.TitleBar;
titleBar.BackgroundColor = Colors.Blue;
titleBar.ButtonBackgroundColor = Colors.Blue
titleBar.ForegroundColor = Colors.White;
titleBar.ButtonForegroundColor = Colors.White;
Call that method to set the title bar colours. I call it from the OnLaunched method to ensure it changes as soon as possible.
A great feature of UWP apps is the ability to create multiple XAML views for different device types, but all using the same code behind file.
Create a separate folder for any device family that requires its own view, using the following naming convention:
Inside these folder, any XAML file (don’t include code behind files) matching an existing file in your project will override it for the folder’s platform, similar to how Windows 8.1 Universal Apps work.
When adding a XAML file to these folders, choose XAML View from the Add New Item window.
Somewhat counter-intuitively, you might find that you can’t see the phone emulators on your platforms drop-down list:
Assuming you’ve installed the emulators, you may be making the same mistake I did…the emulators don’t run on ARM because they run as a VM on your computer, so you need to change from ARM to x86 or x64:
The Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily property will tell you the device family your app is running on (desktop, mobile, etc.) should you need that information.