Posted on by & filed under Content - Highlights and Reviews, Web Development.

Why develop for Windows 8?

Windows 8 is a platform with high potential. Based on the trends, Windows 8 is expected to run on half a billion devices within a year or two. Since previous versions of Windows are already running on over a billion machines today, and upgrading from any existing version will cost a mere $15 to $40 – this is just a deal that is hard to miss. Windows 8 is every bit as stable and incrementally improved in its desktop flavor, but it also has a new and exciting part in its touch-centric start screen and app store support. The tile-based start screen is familiar to anyone who has seen a Windows Phone, which although late in the smart phone game and comparatively underpowered, is winning user satisfaction rankings thanks to its design that works even better on Windows 8. With about 1000 apps in the Windows Store today there is an enormous potential not only in building apps for known brands or innovating with your own ideas, but even remaking apps and websites that already exist today to be able to tap this new opportunity while there is not much competition out there yet. To add to that – you can start developing for free today – developer licenses are free as of this writing.

Why XAML and C#?

On Windows 8 you can develop applications for the Windows Store with one of many technologies. Microsoft is trying to tap developers of various backgrounds to develop the best applications out there, so if you program in C++, C#, Visual Basic or JavaScript – your natural way into Windows 8 app development is to continue using what you know. Windows 8 applications rely on a completely new, modern set of APIs called Windows Runtime (WinRT) that improve upon the old WinAPI and allow you to mix all of these languages in a single application. There has been a lot of buzz about Microsoft switching the focus to HTML5 and JavaScript, and that is true in the sense that they are creating this new development platform that will allow you to use HTML and JavaScript to develop native applications for the first time. The other languages are not left behind, though, and while mature development tools already exist, revolutionary improvements occur with the advent of Windows 8.

Microsoft is known for doing a lot to satisfy developers willing to code for its platforms and has created C# from the ground up, making it one of the most modern, productive and fastest languages out there, which allows you to create your applications quicker than with any other language. Your apps will perform great, have all of the features you can think of, while remaining more maintainable than apps written in any other language. Additionally, separating the declarative user interface layout written with XAML from application logic written with C#, you can separate the design work from development and use tools such as Blend to visually design the interface. Once you learn C# and XAML on Windows 8 you will also find it easy to go back to develop Windows Phone applications with Silverlight, cross-platform Silverlight applications and desktop applications with WPF. Finally, you can combine your C#/XAML applications with C++/DirectX components should you find the need for unique video, graphics or audio features, but you don’t need to use C++ for everything.

Great! How do I start?

Start by grabbing a copy of Windows 8 and Visual Studio. If you are an MSDN subscriber – you can get your copies from MSDN Subscriber Downloads, otherwise – the Windows Dev Center offers a 90 day evaluation version of Windows 8 Enterprise and a free version Visual Studio Express 2012 for Windows 8.

If you have developed in WPF or Silverlight before, you should feel at home with the WinRT/XAML framework (code name Jupiter). If you have not, follow along with me to start building your applications. Like Silverlight before it, Jupiter brings the best parts of WPF to this new platform, while also making some evolutionary changes. Once you start Visual Studio you can create an app project by selecting File/New/Project and choosing the simple “Blank App (XAML)” template as shown in the picture below.

Once the project is created, you can run the app by simply clicking the green triangle icon or pressing F5. If your screen becomes all black don’t panic, everything is fine. The Blank App template is indeed just a blank app with a background that is almost completely black.

Finding your way around the framework

You may notice that the project references the entire “.NET for Windows Store apps” and “Windows”, which are flat views of all available namespaces of the platform. There are no other references that you need to manually add to the project – it is all there. You are just a “using” away from any type that is exposed. Coming from the .NET world you can also see that there are familiar types available, such as App, TextBlock, TextBox, Button or Grid classes, but they are in different namespaces. If you know the name of the type you are looking for you can hover over the entered name and get an option to add the missing “using” statement. The Alt+Shift+F10 shortcut grants the same result. Then again, if you have the full (non-Express) edition of Visual Studio – you can install ReSharper 7, which costs $149 for the Personal License for the C# Edition (there is also a free 30-day trial available), then you can just Alt+Enter/Alt+PgDn through your entire code to make it work and look great. The Object Browser view (Ctrl+W,J) also allows you to search for all available types.

Project structure

The Solution Explorer reveals the file structure of your project and now also allows you to browse to any class member in the integrated view:

Package.appxmanifest is the main configuration file for your application. It defines which type is the entry point to your application (typically the App class), the tile images that show up in the start screen, the capabilities that you want to use (e.g. if you want to use a Webcam in your application you will need to declare it so the app asks for user’s permission to use it), file type associations, charm integrations as well as the “Package name” that uniquely identifies your application.

App.xaml.cs contains the first piece of your C# code that gets executed when the application starts. It has some stub scaffolding to show that it is used to manage your application’s lifecycle management (check LaunchActivatedEventArgs for the list of the many kinds of ways that your application can be launched).

It also sets up the basic shell of your application, which typically consists of a Frame control that you use to navigate back and forth through the history of pages. Here is the simplified code that bootstraps your user interface:

The MainPage class is the only Page of your application for now. The XAML shows it only contains a Grid with a background specified with a brush resource that is almost black. You can take a look at the controls at your disposal on MSDN here.

Finally, you have the StandardStyles.xaml file that contains a resource dictionary with the many control styles for AppBar buttons, TextBlocks etc. that you can use yourself, but that are also used by the item templates that you use when you add a new control to your project (Ctrl+Shift+A).


There is a lot more you can learn from the following resources, but also stay tuned for more posts on Windows 8 development with XAML and C#.

Safari Books Online has the content you need

Check out these Windows 8 books available from Safari Books Online:

Building Windows 8 Applications with C# and XAML shows you how to build immersive, responsive touch apps for Windows 8 tablets, computers, and other devices! Top Microsoft MVP and Wintellect consultant Jeremy Likness shows how to leverage your existing C#, XAML, WPF, or Silverlight skills with new Visual Studio 12 tools and best practices to build incredibly powerful Windows 8/WinRT apps! Likness covers everything from line-of-business to consumer apps, showing exactly how Windows 8/WinRT builds upon and contrasts with earlier WPF/Silverlight development. Using outstanding code examples, he shows how to make the most of new platform features including integrated social networking and search, contracts, charms, and tiles. Building Windows 8 Apps with C# and XAML covers the entire application lifecycle, from planning and MVVM-based design through coding, testing, and beyond. Throughout, Likness addresses crucial development challenges that have only been discussed on MSDN, blog posts, and Twitter feeds — and never with this depth and clarity before. His comprehensive insights and best practices will help readers join the “first wave” of Windows 8 developers — and gain a powerful competitive advantage in Windows development for every new device and form factor. Bonus projects are available for download online. For all experienced and aspiring Microsoft developers and architects, especially those who are at least somewhat familiar with Silverlight, WPF, C#, XAML, and/or related .NET technologies.
Get a head start on building apps for Windows 8. With a series of examples, Getting Started with Windows 8 Apps takes you through the process of creating complete touch-enabled apps that respond to native sensors. Through the course of the book, you’ll learn how to work with the Windows Runtime application model while building a Bing Image Search app.

About this author

Filip Skakun is a Sr. Interactive Developer at Vectorform, where he creates user experiences for the world’s top brands, using the new and upcoming technologies. He is also the creator of the WinRT XAML Toolkit, a popular library for Windows 8 XAML developers. You can catch him on twitter.

Tags: C#, Javascript, Windows 8, XAML,

Comments are closed.