Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#5.0

Hello Windows 10; a pre-release guide for developers

4.93/5 (25 votes)
9 Aug 2015CPOL13 min read 30.1K   287  
I would talk about Windows 10 from a developer's perspective. Windows 10 has not yet been released, but it is better to know the tool to get your hands ready to develop applications.

Introduction and Background

Windows 10 is about to come to public release stage, July 29 is no so far away now (at the time of writing the article). I wanted to take some time to talk about Windows 10 for beginners. I would point out a few key notes about Windows 10, what are requirements to develop for Windows 10, why develop for Windows 10 and how to develop for Windows 10. So these are our key notes that are to be talked about in this article. 
 
Remember, Windows 10 is still in preview. API sets provided are subject to be changed by Microsoft in future.

Windows 10 intro

Windows 10 is next installment of operating system Windows developed, owned and distributed by Microsoft. Some say it would be the last installment of Windows ever, you would receive only updates the system and Windows Update would include more and more features that would make your Windows experience even better and more secure by adding software patches to your system. 

Along with a new OS, there are a lot of more fixes and patches to the system. The interesting one feature for me was Edge (currently named as Project Spartan) as a new version of Internet Explorer. You can consider using Edge for many uses, first of all if you are a PDF reader, and love reading books. Then you would feel easy using the "Reading view" of Edge, also, Edge can convert your web sites into images that you can draw upon, thus be able to share your web page. 
Intro for developers

Coming to the main point of this article, what is Windows 10 as from a developer's perspective. With every previous version of Microsoft Windows, there came another framework version. Specifically speaking, every Windows version was known to have another version of .NET framework shipped with it. New tools, new framework and new updates and features were added to the Windows so that developers can consume them. 
 
Windows 10 is not about a framework or OS. It is about a platform that developers can use to develop their applications on. Windows 10 has introduced a new way of developing applications, Universal Application Platform.  You should not confuse yourself with the Universal Applications for Windows 8 or Windows 8.1. They were a separate concept. They targeted operating system; Windows or Windows Phone. 

Universal Applications (Windows 8, 8.1) Universal Application Platform (Windows 10)
Targets the operating system; Windows 8, 8,1 or Windows Phone 8, 8.1 Targets the device family; depending on which device family (API) you have targeted.
Same shared code-base, different UI for Windows 8, 8.1 or Windows Phone 8.1 Shared code-base same features... Device family ensures the UI features. Adaptive layouts help in this scenario. 
Code is not compiled in native code as is done in other .NET applications, byte code is created for every assembly. Code is compiled down to metal using .NET native compilers.

Let us talk about the common differences (no pun intended)  between the two frameworks. In the universal applications, you have had the same code-base (application logic) but you would have two different projects in your solution; Visual Studio. That concept of Universal did not include Unity; Continuum. Universal Application Platform removes that problem and you now do not have to manage one separate project for each operating system you have to target. Instead you target the types of devices that you need and Windows provides the contracts for you to use for the devices; think of a contract as the API. 
 
There are device families that you target, not operating systems. This removes the ambiguity of different UI features, different components from a designer's perspective. You just need to ensure that the devices that you are going to target have a certain underlying contract. 

Image 1
Image reference: Guide to Universal Windows Platform.

Microsoft is working to bring more and more device families to Windows 10 to enable you to reference them in your work.  A device family is a set of API, or a framework that is ensured to have certain features on a device. If you have a desktop that runs on Windows 10, then if someone targets your device, UAP ensures that a feature is provided regardless of whether that runs or not. For example, your camera. Windows would have APIs to run an application that uses your camera on Desktop but you might not have it at that time. Similarly, if you have a mobile device, Windows would provide the tools to develop application that uses GSM or other mobile network types such as HSDPA (Internet, putting it simply), but you might not have activated the feature for the application to use. In other words, the API would be available even if you have yourself not attached the hardware or have disabled it. 
 
IoT is hot in demand. Old days are back, more green chips, more cables and all. Developers have been working around with a way to configure their applications to work with home automation and similar techniques using hardware components. Microsoft has configured Windows as to run on a small micro-controller also, you can also see a live example of Windows 10 installed on Raspberry Pi 2; a powerful computer in less than $40

FAQs

1. Is device family similar to operating system?
No, a device family is not similar to operating system.  Operating system is required to run your machine, where as the device family is just a compilation of the APIs and features that a developer can use to program an application for that device. 
 
2. How many device families can I target?
Just you could target Windows 8, 8,1 and/or Windows Phone 8, 8.1. You can target one to any number of devices that you want your application to run on. You would have to determine whether an API exists in a device or not, to skip run-time exceptions. 
 
3. What happens if a new device family comes?
That is yet unclear as if to what would happen when a new device family comes, but a simple hypothesis would be that it would be added to the device that can run the API and you can target the family just the way you would do it in current device family range.  

4. What if I want to develop for Desktop and mobile only?
If you want to target the desktop and mobile device family, then you should remove the Universal support and target desktop and mobile families only. This way you will minimize the API check ups (to determine whether a new feature exists) for Xbox, Surface Hub or IoT devices. 

5. What is default device family?
By default Visual Studio would focus on Universal device family (Windows.Universal; look at the Hello Windows 10 example below); which targets Desktop, Mobile... IoT.

Getting started

I would talk about getting started and setting up the environment for Windows 10 development, I am not going to share anything related to coding an application, instead this article is to get your environment ready as I would be continuously posting guides and programming techniques for Windows 10 applications, controls, UI templates, best practices etc. 

First of all, as Microsoft supported Windows 8.1 development in Windows 8.1 only. Similarly, Windows 10 application development has some same rules and validity check before entering the developer portal. You are required to have,

  1. Windows 10
    Of course that is a legitimate reason, you need to have Windows 10 in order to consume  the services and frameworks. Otherwise, you would have to install the features in an old system which would take the same time and same space but with less features. 

    Good things are that you can (for now!) use Windows 10's Insider Preview and then try it out, until July 29 when Windows 10 gets released publicly. Did you reserve your spot?
     
  2. Visual Studio 2015
    Visual Studio 2015 is next installment of Visual Studio IDE provided by Microsoft. Visual Studio 2015 is capable of developing Windows 10 application only. You need to have Visual Studio 2015's any edition. You can try out Community edition for testing purposes by Microsoft. Visual Studio 2015 comes free of cost for small teams, open source projects and other same legitimate conditions. 

You need to have the above mentioned products before you can start developing for Windows 10. You can get them for free for your testing purposes and develop some Hello world applications. Go ahead, download and install them (or do so after completing this article). 

Which language and framework to use? 

Windows 10 can be developed in C#, VB.NET, C++ or even HTML 5. It depends on how you want to use them, you can choose any language that you want to develop your applications. The thing that matters is that you are going to develop applications for Windows Runtime. There won't be any .NET involved. So if you think that the UI or other components seem to sound obvious, they are not. They are controls of Windows Runtime which is a separate framework to develop applications for. .NET also provides tools and kits, but .NET is not being talked about here. 
 
Windows Runtime is also a pretty much old framework, and all of the techniques and How-tos have already been posted by many authors so you won't find yourself chased into trouble at any moment. Also, the structures of the applications is very much neat that any one with how much low knowledge can know what a certain file is intended to do. 

Windows Runtime can be programmed in

  1. C++ (along with XAML or DirectX)
    You can chose whether to use XAML for UI or DirectX. 
  2. C# or VB.NET (along with XAML)
    You can chose which language to use for code-behind. 
  3. JavaScript (along with HTML 5 and CSS 3)
    You do not have any choice but these technologies to chose from!

All of these languages are popular, there are more than thousands of developers using them and most of valuable authors are already posting samples and source codes to these languages. Microsoft has also put a lot of effort in writing samples for these application programming languages. You won't find yourself lonely. 

Windows 10 SDK and tools

Like every software framework, Windows 10 also needs SDK to be installed properly to get started programming applications for Windows 10. You can download Windows 10 SDK officially from here. Otherwise you can download and install any edition of Visual Studio 2015. 

Visual Studio 2015 (any edition) comes shipped with C# 6, Windows 10 SDK & tools and ASP.NET 5. In my opinion, rather than installing a stand-alone SDK you should consider installing Visual Studio 2015. 

Hello Windows 10 example

I might give you an overview of developing the application for Windows 10, In this "Hello world" sample, I would provide the basic application code that would run the application. Windows Runtime is used as the basic building technology for Windows 10 applications, you can although make use of .NET framework and other frameworks, but Windows 10 makes use of Windows Runtime by default, and uses the configuration settings of Universal application platform to provide targeting of clients and devices. 

Creating the project

In Visual Studio 2015, you can find out a difference in Universal applications and Windows 8 applications. Windows 8 applications contain the templates for Windows 8, 8.1 and Windows Phone 8, 8.1 where as Universal application is the home of Windows 10 applications. 

Create a new project and continue reading...

Create a new project

Tinkering with the configuration file

A few things you will notice (if you have ever developed a Windows Runtime application before) is that there is another XML namespace uap added which exposes the functionality and other features of a Windows 10 (Universal application platform) application. You can change the settings your Uap application in those configurations, to update the application-based splash screen, title and other details. 

Have a look at the following configuration file:

XML
<?xml version="1.0" encoding="utf-8"?>

<Package
  xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
  xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  IgnorableNamespaces="uap mp">

  <Identity
    Name="9a866bdd-2ba1-41ca-b9c0-4b2ddda13847"
    Publisher="CN=thecr"
    Version="1.0.0.0" />

  <mp:PhoneIdentity PhoneProductId="9a866bdd-2ba1-41ca-b9c0-4b2ddda13847" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

  <Properties>
    <DisplayName>Hello Windows 10</DisplayName>
    <PublisherDisplayName>Afzaal Ahmad Zeeshan</PublisherDisplayName>
    <Logo>Assets\StoreLogo.png</Logo>
  </Properties>

  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.10069.0" MaxVersionTested="10.0.10069.0" />
  </Dependencies>

  <Resources>
    <Resource Language="x-generate"/>
  </Resources>

  <Applications>
    <Application Id="App"
      Executable="$targetnametoken$.exe"
      EntryPoint="Win10App.App">
      <uap:VisualElements
        DisplayName="Hello Windows 10"
        Square150x150Logo="Assets\Logo.png"
        Square44x44Logo="Assets\SmallLogo.png"
        Description="Win10App"
        BackgroundColor="#464646">
        <uap:SplashScreen Image="Assets\SplashScreen.png" />
      </uap:VisualElements>
    </Application>
  </Applications>

  <Capabilities>
    <Capability Name="internetClient" />
  </Capabilities>
</Package>

You will find that in the above code, there are a few settings that define the configurations for the Windows 10 application. 

As I have mentioned the device family thing, you will see the TargetDeviceFamily element in the Dependencies element. By default, Windows.Universal is targeted you can target other device families (by removing this, because Universal target every device)

You can also edit the settings for each of the application instance for your app in the Applications element under each Application element. The Application is distinguished by the Id, and the code-behind is set by EntryPoint attribute which is the class file to be used.

Managing the UI

Unlike Windows Presentation Foundation or other frameworks, which have a separate Window control to create new application instances. Where as in this (Windows Runtime) there is no such control, there are only Page controls that are used to change the UI dynamically. You can navigate from one Page to another. 

You would create Page controls, add the UI layout and controls to that control and then you would use Navigate function or Frame object to navigate the application to another page. Thus, dynamically changing the layout or UI controls. 

For this sample project's sake I have created a very simple (and familiar) UI for the application, 

XML
<Page
    x:Class="Win10App.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Win10App"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="30">
        <TextBlock FontSize="30">Hello, Windows 10</TextBlock>
        <TextBlock Margin="0, 50, 0, 0" TextWrapping="WrapWholeWords">In a Windows 10 application, you simply define the contents of the application. Rest is assured by the Runtime.</TextBlock>
    </Grid>
</Page>

 

Upon running the application (note that I have not shared the code in this scenario, because all of the code is of Windows Runtime and not anything related to Windows 10 or Universal application platform), the following window pops up and we can see that we did not provide any bounds, size or spacing for the application or the page. Everything is done by the Uap itself.

GUI

The default size of the applications are auto, and you should not edit them instead you should use the Adaptive view that would use current size of application's window (view port) and then update the UI. You will find out rest of the things in upcoming articles. 

As a side note: I have uploaded a sample project for Windows 10 application that you can use and check out, feel free to tinker with it. Add new controls, change the logic and make it yours. :) 

Whats next?

So, this is it for now. In coming up sections and articles I would be posting code samples and suggestions for best UI techniques, best UX practices and other software development items. I would talk about mostly used controls in Windows 10 applications and how you can make use of the previous application's source code. Remember, Windows 10 can be developed using XAML but your Windows Presentation Foundation's XAML is something else. There are most of the things ambiguous in Windows Runtime and Windows Presentation Foundation and you must not get confused. 
 
You should get your environment ready and set up everything (download the required products) I would then continue to post more source code examples for you to test and run. 

Publishing the applications?

Once you have finished developing your application, you can submit the application Windows Store like all other stores. Good thing is that all of your applications, music, books are compiled together into a single library now. So if a user of yours downloads an application, Store would prompt them to have a look at other products that you are offering to your clients, such as music, video, application or a service what-ever Store might support. Store is currently in beta, and would be live once Windows 10 gets released publicly. 

To be continued... :)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)