QUICK TIPS FOR WINDOWS 10 UWP DEVELOPMENT

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 chooseUnload 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:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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.

Comments

Popular posts from this blog

How to prepare your PC for the Windows 10 upgrade Source: WC

Top 5 Japanese Anime (Cartoons)

Salesforce LWC - Mass Approval Component