Developing for Modern Windows

Tips, tricks, and guides for developing on modern Windows platforms

Quick tips for Windows 10 UWP Development

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.

How can I deploy to a non-RTM phone from RTM Windows 10?

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.

1) Right-click your app’s project in the Solution Explorer and choose Unload Project:unload_project

2) Open the project file for editing by right-clicking it and selecting the Edit option:

edit_proj_up3) Change the TargetPlatformMinVersion, e.g. to 10.0.10166.0 to support the (as of this writing) current phone build of Windows 10.

target_platform

4) Reload your project by right-clicking it and selecting Reload Project.

Voila!

How do I Change my App’s Title Bar Colour?

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.

How do I Create Separate XAML Views for Mobile / PC Devices?

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:

DeviceFamily-Mobile

DeviceFamily-IoT

DeviceFamily-Desktop.

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.

Why don’t Phone Emulators Show Up on my Platforms List?

Somewhat counter-intuitively, you might find that you can’t see the phone emulators on your platforms drop-down list:

device_list

No phone emulators but ARM is selected

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:

emulators

Yay! Emulators!

 How do I Detect what Platform Family my App is Running On?

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.

Tags:

2 Responses to “Quick tips for Windows 10 UWP Development”

  1. Paul says:

    Thank a lot for your tips!

    One problem that I’m still have is that a MapControl in does not show any map in a Phone emulator. It only works in the simulator (unfortunately in the simulator you do not have the nice location tooling as in the Phone emulator).

  2. Vladislav Trnka says:

    Thank you for the title bar settings!

    My app looks much nicer than before 🙂

Leave a Reply

Your email address will not be published.