• Migrating apps from Windows 8 to Windows Phone 8

    In this article, I'm listing some of the challenges might be faced when porting a Windows 8 XAML/C# app to Windows Phone 8. I'm assuming it's a content app, like an RSS news reader for example.

    UI pages & controls

    All XAML pages and controls have to be different. UI controls in Windows phone are using different namespaces. And they are actually different, they don't map one to one. Here is a sample of workarounds to replace Windows 8 controls:

    GridView & ListView: these can be replaced by ListBox, ofcourse removing the horizontal scrolling recommended in Windows 8. Everything in Windows Phone scrolls vertically by default. Grouped GridView that are typically used in the hub pages of Windows 8 can be replaced by a Panorama control with each PanoramaItem containing a ListBox.

    FlipView: this one has no replacement in Windows Phone. You just go to a detail page, and you can implement your own flipping technique, may be using the AppBar (next & previous buttons).

    Dark & Light Themes: in Windows 8 the developer can specify which theme to use in an app. On the Phone, the user get to choose which theme from the Settings, so the developer should either abide by using the default theme chosen by user, or he can override the colors for all controls to fix his own theme.

    StandardStyles & LayoutAwarePage: the default project template for Windows Phone 8 doesn't come with the common folder which had these features. The developer is free to create his own version of these files to use as styles or base page.

    Pages & Navigation code

    LoadState: this method should be replaced by overriding OnNavigatedTo.

    Navigation: instead of 
    this.Frame.Navigate(typeof(ItemDetailPage), itemId);
    use
    NavigationService.Navigate(new Uri("/ItemDetailsPage.xaml?ItemID=" + itemId, UriKind.Relative)); 

    Getting Data

    Windows.Data (Json, Xml, HtmlUtility): this namespace is not supported. For reading RSS feeds for example you will have to use LinqToXml instead.

    Internet Connection: instead of
    Windows.Networking.Connectivity.NetworkInformation.
    GetInternetConnectionProfile().GetNetworkConnectivityLevel()
    use:
    Microsoft.Phone.Net.NetworkInformation.NetworkInterface.
    NetworkInterfaceType != Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None 

    Live Tile Notifications: The tiles in Windows Phone are different than Windows 8. In Windows 8 tiles are either square or wide and can be updated using one of the available different templates. In Windows Phone, tiles have 3 sizes, they use one of 3 templates, and biggest change is that they take local image as a URL. So if you want to update the image from the web, you should use ShellTileSchedule class to retrieve the image and update it.


  • How to run the Windows Phone 8 Emulator

    Here are the list of requirements you need to run the Windows Phone 8 emulator:

    Visual Studio 2012 requirements

    64-bit Windows 8 (x64)
    1.6 GHz or faster processor
    4 GB of RAM
    4 GB of available hard disk space

    Windows Phone 8 Emulator requirements

    Windows 8 Pro edition or greater
    Requires a processor that supports Second Level Address Translation (SLAT)
    To check your processor SLAT support, download and run this tool: http://slatstatuscheck.codeplex.com/

    Enable network

    The emulator comes with 3 virtual machines for 3 screen resolutions: WVGA, WXGA, HD 720P. Each one will use a different MAC Address and virtual IP, so in case you are working inside a secure organization, you may need to provision the MAC addresses to enable emulator to access the internet. 

    Publishing your app

    Before you submit your app to the Store, you will need to test your app on the 3 emulators and produce 3 different screenshots for your app to upload to the store. (Lumia 920 is 720P and HTC 8X is WXGA)


  • App Models in Windows Phone 8

    These are the app models that are supported in Windows Phone 8:

    • WP7:
      Apps built for Windows Phone 7 will run in Quirks mode (which is a compatibility mode to run old apps without breaking changes)
    • XAML:
      This is the most common choice for most apps. XAML apps are similar to apps built for Windows Phone 7. They have access to the same APIs (old .NET namespaces that are not available in Windows 8) plus a subset of WinRT APIs (that are available on Windows 8). This choice makes it easy to migrate apps code from both Windows Phone 7 and Windows 8 store apps.
    • Direct3D:
      Direct3D app development is an attractive choice for developers who want the graphics capabilities of Direct3D. It is primarily used by C++ developers to build games that require high performance.
    • HTML5 (Not supported):
      HTML5 & javascript apps like in Windows 8 are not supported in Windows Phone 8. A workaround can be done to create a XAML app and put a web browser control that shows the HTML5 app. However this solution will not allow javascript access to the WinRT APIs and controls, which have to be handled from the XAML code.

  • Publishing to the Windows 8 Store

    I started submitting my first Windows 8 apps to the Store and here is the few issues I faced until now. I'll keep updating this list as I go on.

    • App description should be entered for each supported language in the app manifest.
    • The app must have a privacy policy link inside the settings charm and in the store page.
    • The app must have a support link in the store page.
    • The app must provide value to the target markets. For example an Arabic only app will not be accepted in non Arabic speaking countries.


  • Windows 8 Start Kit

    I've been working on this for the past few weeks, and it's out there now.

    An open source library, sample application and documentation for creating robust Windows 8 apps.

    Check it out on github: https://github.com/LinkDev/Windows8StartKit#windows-8-start-kit

    Read the wiki, use the sample application code in your apps, and contribute back.

    Features

    • NewApp project that uses the library features and will give you a fast start.
    • A set of classes for common applications data.
    • Auto saving/loading for your app data in local cache.
    • Read multiple feeds including RSS or customize your own.
    • Schedule feeds to refresh every time interval.
    • Show live tile notifications.
    • Enable content sharing.
    • Show progress bar when a feed is being loaded.
    • Preserve memory usage by disposing images after closing a page.
    • Helper classes for easy XAML data binding.


  • Windows8: Choosing Light or Dark Theme

    You can choose between Dark and Light theme by changing RequestedTheme in the App.xaml file, like below:


    <Application
       x:Class="HelloWorld.App"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:local="using:HelloWorld"
       
    RequestedTheme="Light">


  • Windows8: Disable ScrollViewer zoom

    When using ScrollViewer control, the default behavior is ZoomMode="Enabled" which allow the user to zoom in and out with touch gestures. If you don’t want this behavior (because it may ruin your design or user experience), make sure that you set ZoomMode=”Disabled” for all ScrollViewer controls.


  • Windows8: Changing theme colors

    This is the second article in my Windows 8 best practices series.

    To change the colors of the default theme, add the following keys anywhere in the StandardStyles.xaml and change them accordingly:

    <SolidColorBrush x:Key="ApplicationPageBackgroundThemeBrush" Color="#FFFFFF"/>

    <SolidColorBrush x:Key="ApplicationForegroundThemeBrush" Color="#333333"/>

    <SolidColorBrush x:Key="ApplicationSecondaryForegroundThemeBrush" Color="#FF991100"/>

    <SolidColorBrush x:Key="ApplicationPointerOverForegroundThemeBrush" Color="#AAAAAA"/>

    <SolidColorBrush x:Key="BackButtonBackgroundThemeBrush" Color="#00000000"/>

    <SolidColorBrush x:Key="BackButtonForegroundThemeBrush" Color="#FFFFFF"/>

    <SolidColorBrush x:Key="BackButtonPressedBackgroundThemeBrush" Color="#00000000"/>

    <SolidColorBrush x:Key="BackButtonPressedForegroundThemeBrush" Color="#CCCCCC"/>

    <SolidColorBrush x:Key="BackButtonPointerOverBackgroundThemeBrush" Color="#00000000"/>


  • Windows8: Arabic & RTL

    This is the first article of a series of Windows 8 development best practices.

    This is a detailed how to convert a new project template to an Arabic right to left ready project.

    1. Change FlowDirection="RightToLeft" in all pages root element.
    2. Change the back button arrow direction by applying the following changes in StandardStyles.xaml:

      Put the following instead of the first part of the file:

          <ResourceDictionary.ThemeDictionaries>
              <ResourceDictionary x:Key="Default">
                  <x:String x:Key="BackButtonGlyph">&#xE0AA;</x:String>
                  <x:String x:Key="BackButtonSnappedGlyph">&#xE0AC;</x:String>
              </ResourceDictionary>
              <ResourceDictionary x:Key="HighContrast">
                  <x:String x:Key="BackButtonGlyph">&#xE0AA;</x:String>
                  <x:String x:Key="BackButtonSnappedGlyph">&#xE0AC;</x:String>
              </ResourceDictionary>
          </ResourceDictionary.ThemeDictionaries>

      Find: BackButtonStyle, and put &#xE0AB; in the ArrowGlyph Text value.
      Find: SnappedBackButtonStyle, and put &#xE0AD; in the ArrowGlyph Text value.

    3. Increase the font sizes to be appropriate for Arabic text.

    Try it and tell me your feedback :)


  • Blox World beta launch

    I'm pleased to announce the beta launch of my game Blox World

    It's a facebook game about building anything you can imagine using blocks, sharing it with your friends and competing with them in solving missions.

    Play it now