I have long wanted to develop an application for Windows 8. However, I began to embody the dream as soon as Windows 8.1 was released. I looked at the application store, but it is empty, especially in Russian there is almost nothing, and what is - with the translation via google translate.
In this article I will try to note the most interesting moments connected with the development of an application for win 8.1.
Question: where to start development? I want something simple and useful for myself. So: Sudoku.
Sudoku windows 8.1

')
Sudoku is a 9x9 square that is divided into smaller 3x3 squares.
The goal of the game is to fill the free cells with numbers from 1 to 9 so that in each column, row and in the small square each number meets only once.
Training
To develop a mobile application on Windows 8.1 you will need:
- Microsoft Visual Studio 2013
- Blend 2013
- The idea of the application
- Design or layout of the application
I divided the solution into 2 projects: Core and a project for Windows 8.1. Core made all the main modules that can be used on other platforms. This is an implementation of the algorithm, enumeration and data model).
Core is created as a
Portable Class Library . What a surprise when I didn’t find in it support for async / await and some other classes from the standard .NET set. This is solved by connecting nuget packages:
Microsoft.Bcl ,
Microsoft.Bcl.Async ,
Microsoft.Bcl.Build, and additionally connecting
Newtonsoft.Json for data serialization.
Application life cycle
All applications for the Windows app store follow this life cycle (see picture). When the application starts, it gets the status of Running. Then, when the user shuts down or collapses the application, or in other cases, the program will receive a notification about Suspending. If the operating system decides to close the application from Suspended mode, there will be no additional notifications. If the application is restored from this mode, there will be a corresponding notification.

The application does not receive a closing notification. The only way to save important user data is to handle the
OnSuspending
event in
App.xaml.cs
In order to test switching between modes, you need to enable an additional
ToolBar (DebugLocation) , an application control panel will appear.

When creating a project, VS creates additional classes. One of them is
SuspensionManager
, which creates wrappers for asynchronous saving and restoring data. It is important to do this asynchronously, so that, firstly, the user does not wait for the application to load / unload, secondly, because the application is given a certain final time to save its state.
Graphics
There were a lot of surprises with graphics. A huge plus OS, that it is supported on many devices. But for this you need to do everything right.
As for the images: you need to upload them in several scales. The file is loaded by the usual name, and physically in the project there are, for example, the following files:
en-us \ logo.scale-100.png, en-us \ logo.scale-140.png . Something similar is with iOS development, where images are saved in 2 sizes (retina and not retina) and are named
image@2x.png and
image.png, respectively.
In Windows 8.1 (and 8 too) you need to prepare 4 image sizes for scales: 80, 100, 140, 180. You can read more about this
in Russian and
here (msdn) .
In my project, I chose a background of the maximum size and did not create additional images, but set
Stretch = UniformToFill.
Special attention is given to the creation of a logo. Here I had to tinker and create it in all recommended sizes, so there were a lot of files:

Application structure
It was decided to make the application on the same page (and more is not needed). I wanted a simple application, without annoying forms, WITHOUT ADVERTISEMENT. A simple application for the game. I found that it is possible to launch Desktop applications with an application attached from Snapped from a store, which turned out to be very convenient on widescreen monitors. So in the list of women, this mode was added to the portrait and Filled. Total 4 options for the structure of the application.

Blend
The Blend tool itself is convenient for creating the design of the application (if you do not pay attention to its frequent errors). On the game page I placed all the controls in advance, and in the dynamics when changing the size or mode I will switch them.

Further, depending on the position of the screen, I change the size. IMPORTANT to change font size too. Since 15 pt on a 2500px monitor will be less than noticeable.
I do something like this:
Resize Code double scaleFactor = stackControlsWidth / StyleHelper.StackControlsBaseWidth;
Panes
As an element from the new management system for the Panes application settings, it was decided to add at least 1 Pane (About the application).

Connect it as follows protected override void OnWindowCreated(WindowCreatedEventArgs args) { SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested; } private void OnCommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args) { args.Request.ApplicationCommands.Add(new SettingsCommand( "About", " ", (handler) => ShowCustomSettingFlyout())); } public void ShowCustomSettingFlyout() { AboutFlyout CustomSettingFlyout = new AboutFlyout(); CustomSettingFlyout.Show(); }
Themes
2 additional View created to select a new game and congratulations on the successful passage of the current

These views also need to be made scalable.
Publication
The publishing process turned out to be very interesting. Surprisingly, the application was published in the store total account for 8 hours, taking into account one failure.

Refused due to the lack of a certificate of age for the game. It turns out that in Russia a certificate of age is required for games.

According to the documentation created a certificate and sent for moderation again. The second time the application passed all the checks in 2 hours and turned out to be available in the store. It is worth noting that the application is very simple. Does not contain network connectivity or other features. Also, there is no need to talk about any content that can be checked, it simply does not exist.
Results
Developed an application for
40 hours. Truth made him 1 month. The application turned out easy, fast and, in my opinion, convenient to use. The first version did not get the initial ideas, such as: cancellation of the move, hints, table of results (from the server). I think I will do it in updates if there are people willing and playing.
Support for all screen resolutions and 4 application modes (Full, Filled, Snapped, Portrait).
Published application without ads and SMS, now I am doing the WinPhone version. If you want to help, I’m ready to open the source code and publish it in co-authorship (Win 8.1 has done so).
