Sharing Code between Windows, WinRT and Windows Phone

Monday, December 16, 2013

In recent times, I often find myself developing for more than one “Windows” platform – typically Windows Phone and Windows 8 Store and sometimes Windows (WPF) as well. In this post, I’d like to share some of the tools and techniques I’ve been using to ease code sharing. Portable Class Libraries (PCLs) PCLs came out in Visual Studio 2012 and provide an easy way to create a single project that can be referenced by multiple project types. When you create a PCL, you get the following dialog: This dialog allows you to select multiple targeted platforms (at...

My first PluralSight course has been published!

Thursday, August 8, 2013

In the last few months, I’ve been working on a course for PluralSight. Creating a video course is not easy, as I found out first hand. In fact, it’s more difficult than writing a book. With a book, I can change a sentence or a paragraph, at any time and any place. A video course is different… changes are hard, and recording sessions cannot be done just anywhere. But I’ve learned a lot from the experience, which should make next courses a bit easier…My first course is about a favorite subject of mine, Windows Internals. This deals with the...

Build 2013 Summary

Saturday, June 29, 2013

The Microsoft Build 2013 conference is now over, so it’s time for some summaries and impressions. All the following is my personal thoughts from my viewpoint, and may not reflect the way things actually are. Last caveat – some of the information is based on the sessions I attended. Naturally, I couldn’t attend most sessions, and I may not even remember all info given in the session I attended. Still…The conference was 3 days in length. With about 14 sessions going on at the same time slot, this is too short a conference; 4 days would have been better....

My Wish List for Windows “Blue”

Friday, May 17, 2013

Many rumors are flying around at this time about the upcoming release of Windows 8.1 (code named “Blue”, which represents a wave of product updates, including Windows Phone and others). I thought I‘d state my hopes for this release, not just in terms of user features, but also from a developer’s perspective. As a developer, I spend most of my time on my trusty laptop, not some tablet based device. Naturally, the desktop world is my friend. The Windows 8 Start screen is close to perfect for tablet devices, but for the desktop – it’s practically useless. With many...

My New Book Project

Tuesday, March 5, 2013

Those of you who follow my blog may have noticed a slowdown in posts. The main reason for this is that I am working on a new book, titled “Windows 8 C++ App Development” to published by Packt Publishing in about 2 months time.The book has now an official URL in Pack’s web site (no Amazon link yet, but soon…).The book is aimed towards C++ developers that want to use the power and flexibility of C++ to write Windows 8 Store Apps, while leveraging XAML as the UI technology. It includes a good coverage of C++/CX and most features...

XAML Tip: Graphics with ItemsControl

Saturday, February 23, 2013

Sometimes in a WPF or Windows Store or Windows Phone application we need to draw some things based on some collection of data items. Suppose we have the following simple data item: class CarData { public double Distance { get; set; } public string Image { get; set; }}Suppose we have a collection of CarData objects, and the requirement was to show a set of images along a line with a particular distance, like in the following screenshot:The distance from the left is determined by the Distance property, and the image is determined by...

Making HTTP calls in WinRT with C++

Monday, January 14, 2013

When working with Windows Store applications (“metro”), it’s sometimes necessary to make HTTP calls. one classic example is to register for push notifications. After obtaining a unique channel URI, the app needs to send that URI to its application server, as that particular URI is the one to use by the application server to execute a push notification against the Windows Notification Service (WNS).Getting the channel URI is fairly simple, with a call to the static PushNotificationChannelManager::CreatePushNotificationChannelForApplicationAsync method. Now comes the tricky part: how to send the resulting URI to the application server?In .NET, things are relatively easy. Just use...

Windows Runtime with C++/C#: Anatomy of a WinRT Class

Sunday, December 30, 2012

The Windows Runtime (WinRT) is based on COM (I referred to it in the past as a “better COM”), which means every method and property must be part of an interface. Also, COM does not support static members (only instance members) and does not easily support parameterized constructors. Inheritance is again an issue in classic COM – the closest thing is COM aggregation, and that’s not really inheritance in the usual sense of the word.Using C++/CX or a .NET language allows creating WinRT types that support methods, properties, constructors and static members, and even events (another feature that is...

Preview of Blend 5 available

Tuesday, December 25, 2012

When Visual Studio 2012 came out, one thing was sorely missing. An Expression Blend tool that can handle WPF 4.5 applications. Blend for Visual Studio that is currently available only supports Windows 8 Store Apps, but not WPF (or Silverlight).A few days ago, Microsoft released a preview of Blend 5 (with Sketchflow), that’s able to work with WPF and Silverlight, along with Windows 8 Store apps.The tool can be downloaded from here: stated that the final version of the tool will be available with Update 2 of Visual Studio 2012 (Update 1 was released about 2 weeks ago).
no comments

Windows Runtime: Where did TemplatePart go?

Thursday, December 13, 2012

In WPF and Silverlight, controls define their named parts (those that have them) using the TemplatePart attribute. For example, here’s the class definition for the WPF ProgressBar control:  public class ProgressBar : RangeBase{This indicates to those wanting to replace the control template which named parts are understood (and searched for) by the control. XAML based tools can also use this information to provide better user experience for authoring templates.In WinRT, the TemplatePart attribute is defined, but looking at control metadata – it...