Pre-beta Windows 8.1 WinRT Developer APIs

Justin Angel picture

Justin
Angel

Hi folks,

In this article we’ll review new developer WinRT features that’ll be released in the upcoming Windows 8 release (dubbed “Windows 8.1” / “Windows Blue”). Microsoft recently announced that during June 2013’s BUILD conference a developer preview of Windows 8.1 will be released for download. In the meanwhile many Windows 8.1 “leaked” images are available online. These “leaked” images allows us to get a sneak preview of the featuresets that’ll be announced in BUILD conference. For the length of this article we’ll go over those features.

Windows 8.1 fake logo

 

Methodology: How was this research done?

Windows 8.1 images contain WinMD files describing their embedded Windows 8.1 developers APIs. It’s possible to get to Win8.1’s WinMD files and then compare them to the existing Windows 8 RTM WinMD files. This entire article is based upon using Reflection to see those API differences.

  1. Download the latest Windows 8.1 “leaked” image. This article was based on an image named “9385.0.FBL_PARTNER_OUT17.130415-2049_X86FRE_CLIENT_EN-US-PL-PL-RU-RU.ISO”.
  2. Create a bootable USB drive from the ISO file and Install it on a nearby machine.
  3. Win8.1’s WinMD files can be found under the following directory: C:\Windows\System32\WinMetadata
  4. Using Microsoft’s Framework Design Studio it’s then possible to compare the WinMD files from a WIndows 8.1 “leaked” image and Windows 8 RTM. 

Framework Design Studio comparing Win8.1 and Win8 APIs

For your easy reference you can download the aforementioned WinMD folder from here: Windows 8 RTM WinMDs, Windows 8.1 9385 WinMDs.

The resulting comparison between Windows 8 and Windows 8.1 API can be downloaded from @ http://justinangel.net/storage/windows81/WinMDDelta.zip 

 

Table of Contents

  1. Bluetooth 4.0 RfComm and GATT support
  2. Point of sale: Barcode scanners and Magnetic card readers
  3. Smart Cards
  4. Lock screen Image Apps
  5. VPN support for Metro apps
  6. Scanner APIs and apps
  7. Support for any External / USB device
  8. Native PDF rendering in apps
  9. Multiple screens projection support in apps
  10. XAML/WinJS: New resolution scaling support / Super-high resolution tablets
  11. Camera: Low-lag cameras / HDR
  12. New Metro App Types: Appointments, LockScreen, Contacts and GeoLoc
  13. New App Type: GeoFenced activation
  14. New App Type: Lock screen call
  15. New App Type: Appointments Provider
  16. Text-to-speech
  17. Read-write access to Camera roll, Saved pictures and playlists
  18. XAML/WinJS: new SearchBox control
  19. XAML/WinJS: Hubs for SemanticZoom
  20. XAML: DatePicker and TimePicker
  21. XAML: Flyout, MenuFlyout and SettingsMenuFlyout
  22. XAML: AppBar simplification
  23. XAML: DataBinding Improvements
  24. Globalization: Currencies, Numeral systems and Numerical formatters
  25. Other minor but important Win8.1 features
  26. How to code Win8.1 C# apps before public beta?
  27. How to develop Win8.1 WinJS apps before public beta?
  28. Disclaimer: Please don’t sue me

 

Jump back to table of contents  

Bluetooth 4.0 RfComm and GATT support

Windows 8 had no support for developers to interact with external bluetooth-enabled devices. PeerFinder was there but it wasn’t bluetooth capable. It’s a pleasant surprise to see Windows 8.1 support both RfComm bluetooth protocol and GATT bluetooth profile which are the core of Bluetooth 4.0 support.

RfComm is an underlying protocol used for communicating between two bluetooth enabled devices. RfComm is comparable to TCP in that TCP communicates between two WLAN enabled devices and RfComm is communicates between two bluetooth capable devices. RfComm can be used with the majority of bluetooth devices even if those don’t expose their own developer APIs and services. As we can see from these new Windows 8.1 types RfComm is fully supported:

Windows.Devices.Bluetooth.Rfcomm namespace class diagram

In addition to RfComm Win8.1 will also have comprehensive GATT support. GATT is a core component of supporting the latest generation Bluetooth Low Energy devices. Using GATT Win8.1 can support a multitude of long-running low-power devices such as: Heart rate monitors, thermometers, glucose readers, pedometers, running speed monitors, proximity sensors and general notification devices. As we can see from the following classes there’s ample support for GATT in Windows 8.1:

Windows.Devices.Bluetooth.GenericAttributeProfile namespace class diagram

With Bluetooth 4.0 support in Windows 8.1 we’ll see a many external bluetooth-enabled devices connect to WinRT. The aforementioned GattCharacteristicUuids class mentions a lot of those supported devices.

 

Jump back to table of contents  

Point of sale: Barcode scanners and Magnetic card readers

It was previously revealed that Windows 8.1 will support Kiosk mode. Windows 8.1 has new APIs for Magnetic card readers and barcode scanners. So it’s pretty clear to say Microsoft is aiming for a new class of WinRT cash register apps (“Point of Sale”).

Print screen showing Kiosk mode settings in Win8.1

 

In the following class diagram we can see the new Win8.1 barcode scanner support. It all comes down to the ClaimedBarcodeScanner.DataRecieved event which will provide a byte[] array with the barcode data.

Windows.Devices.PointOfService namespace barcode class diagram

There’s also a BarcodeSymbologies class partially shown above that claims the API supports the following barcode systems: AusPostal, Aztec, Bookland, CanPostal, Cca, Ccb, Ccc, Chinese2of5, Codabar, Code11, Code128, Code128Parsed, Code32, Code39, Code93, CompositeAB, CompositeC, Coupon, CueCode, DataMatrix, Doccap, DutchPostal, Ean128, Ean13S, Ean8S, EanJan13, EanJan8, ExtendedBase, GS1DataBar, GS1DataBarExpanded, GS1DataBarExpandedStacked, GS1DataBarStackedOmnidirectional, Iata2of5, Image, Isbt128, Itf, JapPostal, Korean3of5, Macromicropdf, Macropdf, Matrix2of5, Maxicode, Micropdf, MicroPdf417, MicroQRCode, Msi, Ocra, Ocrb, Pdf417, QRCode, Rss14, Rssexp, Rsslim, Signature, TF, Tlc39, Trioptic39, UkPostal, Unknown, Upca, Upcas, Upcd1, Upcd2, Upcd3, Upcd4, Upcd5, Upce, Upce0, Upce1, Upces, Us4state, US4statefics, UsPlanet, UsPostNet and Webcode. 

There’s also a new API for magnetic card readers which we can see below. There’s lots of goodies in this API. Starting from generic Magnetic card reader support with direct access to reading Track1-4 data. There’s also Encryption support for Triple DES blocks. And there’s even built-in support to bank cards and AAMVA vehicle driver data. Overall it seems like a great magnetic card reader API that’ll support everything from store cards, bank cards, AAMVA cards and any custom 3rd party magnetic cards.

Windows.Devices.PointOfService magnetic card reader namespace class diagram

 

 

Jump back to table of contents  

Smart Cards

One of the interesting new security minded features in the Win8.1 APIs is the support for Smart Cards and pin challenges. For those who are unaware “Smart cards” is a generic name for cards with integrated circuits that help uniquely identify cards. Some well known smart cards include credit cards, debit cards, employee cards, public transit payment cards and more.

integrated circuit on a bank card

 

The new Smart Card API in Windows 8.1 allows us to iterate over plugged-in smart cards, challenge the user for pin card authorization, reset challenge pins and even to create or destroy cards. As anyone with a bank card knows challenging users for pin codes is quite useful in real-world scenarios.

Windows.Security.SmartCards namespace class diagram

It’s really interesting to see that the Win81 APIs allow for both day-to-day usage of smart cards and managing smart cards.

credit card payment terminal issuing a pin challenge for a user.

 

Jump back to table of contents  

Lock screen Image Apps

It’s been previously reveled that Windows 8.1 apps can now set the lockscreen background image.

2013-05-12_12-14-10

 

Windows 8.1 apps can set the lock screen image to a remote feed. While the format of the remote feed is currently unknown (RSS? Media RSS?) it’s likely to be fairly simple to implement. The beautiful part about setting the lock screen to a remote feed is that changing the picture doesn’t require running the app or any custom code on the client side.

namespace Windows.System.UserProfile 
{
    public static class LockScreen 
    {
        public static IAsyncOperation RequestSetImageFeedAsync(void syndicationFeedUri);
        public static Boolean TryRemoveImageFeed();
    }

    public enum SetImageFeedResult 
    {
        Success,
        ChangeDisabled,
        UserCanceled
    }
} 

 

Jump back to table of contents  

VPN support for Metro apps

A very common complaint for Windows 8 Metro apps is that they sometimes stop working under most VPN connections. VPNs are critical for many people including Iranian employees and remote dissidents (or is it “Iranian dissidents and remote employees”?).

picture illustrating what VPN is for dummies

It’s great to see Microsoft adding a whole new Windows.Networking.vpn namespace to help deal with VPNs in WinRT apps.  The new VPN API featureset is fundamentally about sending encrypted packets. It also supports VPN routing (what goes in the VPN connection and what doesn’t), multiple VPN authentication methods (username, password, pin, smart card, credentials and more) and support for VPN namespaces. I

Windows.Networking.vpn namespace class diagram 

Despite the plethora of new VPN APIs, an open question remains as to whether WinRT Win8.1 apps will work by default on VPNs.

 

Jump back to table of contents  

Scanner APIs and apps

Windows 8 introduced a new type of Metro apps that are associated with printers. Those apps can be used to define a custom printing configuration within the Windows 8 “devices” charm. However, scanners were conspicuously unsupported and didn’t have that level of support. Scanners weren’t usable in Metro apps and the scanner manufacturers couldn’t hook into the Win8 “devices” charm. Well, that’s going to change in Win8.1. 

Scanner and windows 8 logo

Using the new Windows.Devices.Scanners namespace apps can automate scanning and customizing documents from flatbed & feeder scanners. Developers can see current scanner configuration, set a few properties (auto cropping, color mode, contrast, resolution, etc) and get image files after scanning.

Windows.Devices.Scanners namespace class diagram

An open question is whether or not Scanner OEM apps written by device manufacturers will be supported in Windows 8.1. Looking at the impressive API above, I’d be surprised if they won’t be supported.

 

Jump back to table of contents  

Support for any IO and USB device

One of the big limitations of Win8 WinRT apps is their lack of ability to interact with connected and built-in devices unless previously exposed by WinRT. It seems that’s about to change in Windows 8.1 with the introduction of the new Windows.Devices.Usb and Windows.Devices.Custom namespaces.  Both of these namespace provide IOutputStream and IInputStream to any USB or IO device. It’s fair to assume it’ll be heavily gated by permissions, but it’s still a great feature that opens up new avenues for Win8.1 apps.

Data comes in, data goes out. You can't explain that.

Below we can see the new Windows.Devices.Custom namespace with the Input & Output streams highlighted. The code to use this API would be fairly straightforward. First we’d get a DeviceID or Device selector string from existing Win8 APIs, next we’d get a CustomDevice instance and finally we’ll send over IOControlCodes the device will recognize.

 Windows.Devices.Custom namespace class diagram

Another new API that is more USB specific was introduced is the Windows.Devices.Usb namespace. Below you can see the types of USB devices supported, and where the Output and Input streams can be found. 

Windows.Devices.Usb namespace class diagram

The new USB namespace is quite verbose so I’ve highlighted only what I felt is the most self explanatory API.

 

Jump back to table of contents  

Native PDF rendering in apps

Windows 8 developers hoping to author an alternative PDF viewer Metro app were in for quite a shock. They had to develop their own C++ PDF rendering engine. Obviously, that’s a considerable task and despite being a  very common one. That’s why it’s great to see Windows 8.1 introduces built-in support for all apps to render PDF documents. Below we can see the majority of top rated PDF viewer in the Win8 store are all in-fact Desktop apps and not WInRT apps:

majority of top rated PDF viewer in the Win8 store are all in-fact Desktop apps

The new Win8.1 PDF API starts by loading a PDF file using PdfDocument.LoadFromFileAsync(), getting the total number of pages and then invoking PdfDocument.GetPage(i).RenderToStreamAsync(). Once we have the image stream it should be quite simple to add it into any app UI.

Windows.Data.Pdf namespace class diagram

 

Jump back to table of contents  

Multiple screens projection support in apps

Imagine watching a video on your Win8 atom-based tablet and plugging it into your TV. The tablet could duplicate the content on the TV, but it can’t choose to show one view for the TV and another view for the tablet screen. That for example is the experience for the Netflix iPad app. In windows 8 Metro apps were spectacularly single screened and only had one single active view. It seems that in Windows 8.1 developers can opt-in to create additional alternate views for projection displays.

2013-05-12_18-08-18

Windows 8.1 Introduces a ProjectionManager class that allows developers to listen to projection display changes and provide multiple displays with their own unique views.

namespace Windows.UI.ViewManagement
{
    public static class ProjectionManager
    {
        public static IAsyncAction StartProjectingAsync(int projectionViewId, int anchorViewId);
        public static IAsyncAction SwapDisplaysForViewsAsync(int projectionViewId, int anchorViewId);
        public static IAsyncAction StopProjectingAsync(int projectionViewId, int anchorViewId);
        public static bool ProjectionDisplayAvailable { get; }
        public static event EventHandler<object> ProjectionDisplayAvailableChanged;
    }
}

 

Jump back to table of contents  

XAML/WinJS: New resolution scaling support / Super-high resolution tablets

It’s possible we’ll see Win8.1 WinRT tablets sporting screens with much higher DPI then Apple’s retina even going all the way up to “4k” resolution.

Win8 supports loading different media resources in different DPIs. Essentially making it quite easy to change images and videos and create a DPI-Independent apps.  This is done by specifying the same resource in multiple “scaling factors”. You can read more about scaling factors on Win8’s official blog.  It’s interesting that additional scaling factors have been added to Win8.1 showing Microsoft has an expectation for higher-resolution tablets.

  public enum ResolutionScale
  {
    Invalid = 0,
    Scale100Percent = 100,
    Scale140Percent = 140,
    [Version(100859904)] Scale150Percent = 150,
    [Version(100859904)] Scale160Percent = 160,
    Scale180Percent = 180,
    [Version(100859904)] Scale225Percent = 225,
  }

As we can see the highest new scaling factor supported is 225%. That’s 25% higher DPI that Microsoft expects to run on Win8.1 WinRT tablets then on Win8 WinRT tablets. Current scaling values correspond to real resolution and DPI as follows assuming a 12.5”-13” display:

current ScalePercents explained by MSDN

The existing 180% scaling supports 240DPI in WQHD resolution, so it’s reasonable to assume that 225% scaling would support 300DPI and even higher values. It’s possible we’ll see Win8.1 WinRT tablets sporting screens with much higher DPI then Apple’s retina even going all the way up to “4k” resolution.

 

Jump back to table of contents  

Camera: Low-lag cameras / HDR

There are new Win8.1 APIs introduced to support “Low Lag Cameras” which could indicate Microsoft is expecting HDR capable cameras in WinRT Tablets.

As we can see below Win8.1 introduces a lot of new “Low Lag” media capture APIs:

Windows.Media.Devices naemspace LowLag class diagram

As we can see this API will allow developers to take multiple low lag images in sequence which is a prerequisite to HDR custom stitching algorithms.

“Low Lag” cameras could mean a few things. Let’s first try to explain what Camera Lag is. In digital cameras users first see a thumbnail preview of the image being taken, they then click the “take picture” button and finally they see the final picture. The final picture is often different from the thumbnail preview as cameras need a few hundred milliseconds to actually take pictures. That time between clicking the “take picture” button and the time the picture is actually taken is called “camera lag”. Most cellphones and tablets have greater lag then other digital cameras as they don’t have a physical camera shutter. PC Magazine has a expanded explanation on this topic and more statistics.

Average Shutter lag in cellphones from PC Magazine

So what’s a “Low Lag" Camera good for? First it’ll let users take better pictures due to the reduced lag. Second, it can be used for HDR. HDR is essentially taking multiple nearly identical pictures in different exposure values and stitching them together.  For example, a picture with high exposure will provide better visuals for shadows; and a picture with low exposure will have bright objects such as the sun and lamps look better. By stitching the best part of each exposure value we get a much better digital picture. Low lag cameras are essential for HDR as we can’t have too much time between capturing photos or stitching them won’t be feasible. You can read more about HDR here.

HDR Illustrated

 

 

Jump back to table of contents  

New Metro App Types: Appointments, LockScreen, Contacts and GeoLoc

The way Metro apps are launched is often strongly associated  with major featuresets in WinRT. Such Win8 featuresets include Search charm integration, Share charm integration, FileOpenPicker/FileOpenPicker integration, app2app file associations, etc. In Win8.1 the list of activation types in WinRT has been expanded to include lock screen calls, appointments provider, contacts provider and geolocation launching.

namespace Windows.ApplicationModel.Activation
{
  [Version(100794368)]
  public enum ActivationKind
  {
    Launch,
    Search,
    ShareTarget,
    File,
    Protocol,
    FileOpenPicker,
    FileSavePicker,
    CachedFileUpdater,
    ContactPicker,
    Device,
    PrintTaskSettings,
    CameraSettings,
    [Version(100859904)] RestrictedLaunch,
    [Version(100859904)] AppointmentsProvider,
    [Version(100859904)] Contact,
    [Version(100859904)] ContactsProvider,
    [Version(100859904)] LockScreenCall,
  }
}

 

Jump back to table of contents  

New App Type: GeoFenced activation

With WIn8.1 apps can now register to be launched once the user leaves or enters a specific Geolocation area. There are many usecases this can be useful in, for example : keeping tabs that small children don’t stray too far, launching an app once entering a restaurant, etc.

image

 

The API itself is pretty straightforward. Win8.1 apps that want to be launched due to exiting or entering a GeoFence area first need to register a LocaitonTrigger the same way they’d register any other IBackgroundTrigger. Next apps need to register additional instances of the GeoFence class with a center point and a radius around that point.

Windows.Devices.Geolocation.Geofencing namespace class diagram

There are a few puzzling open questions about this featureset. Can it be used to Geofence media content? For example, can Netflix use this to limit distribution of just some films to U.S. Markets? Another interesting open question is why limit GeoFencing to circular areas and not rectangular areas? This API seems like it’s got some evolution to do prior to be released to the general public.   

 

Jump back to table of contents  

New App Type: Lock screen call

Win8.1 will include the capability to launch VoIP apps to start/end phone calls while the OS is locked. Essentially if a user gets a skype audio call under lock screen, you we want them to first unlock their tablet and then answer; we want them to just answer audio calls with a single tap. Which is why the new LockScreenCallActivatedEventArgs makes a lot of sense.  Win8.1 apps also be able to set a call title on the lock screen to show up with the default lock screen UI.

Windows.ApplicationModel LockScreenCall  namespace class diagram

 

Jump back to table of contents  

New App Type: Appointments Provider

Using the new AppointmentsProvider apps can add and manage additional meetings to the shared Win8.1 calendar. Using this functionality developers can integrate 3rd party calendars into the main Win8.1 calendar. The AppointmentsProvider functionality launches the app asking for appointments in a specific time-frame. Appointments may also be sent back to our app to be added, removed, replaced or launched. 

Windows.ApplicationModel AppointmentProvider class diagram

With the new AppointmentProvider the ability to show the built-in calendar and individually ask the user to add, replace or launch appointments from it.

Windows.ApplicationModel.Appointments namespace class diagram

 

Jump back to table of contents  

Text-to-speech

Windows 8 apps that integrated text-to-speech capabilities needed to use a web-based TTS service. That had the disadvantage of requiring a network connection and had some lag associated with it. Win8.1 adds text-to-speech support to WinRT apps using Microsoft’s Speech platform.  The API itself is straightforward as you can se below. 

Windows.Media.SpeechSynthesis namespace class diagram

As we can see above Win8.1’s text-to-speech API supports iterating over installed voicces, choosing a voice to speak, using either plain text or SSML and getting back a SpeechSynthesisStream. For example the following code snippet would say “Hello world”.

        <MediaElement x:Name="media" />
        var speech = new SpeechSynthesizer();
        var stream = await speech.SynthesizeTextToStreamAsync("Hello World");
        media.SetSource(stream, "audio/wav");
        media.Play();

 

Jump back to table of contents  

Read-write access to Camera roll, Saved pictures and playlists

The KnownFolders class provides WinRT apps access to many windows folders such as music, pictures, documents and others. In Win8.1 The list of accessible folders expanded to contain the playlists folders, saved pictures and camera roll. That indicates that Metro Win8.1 apps can read and write from those folders. 

namespace Windows.Storage
{
  public static class KnownFolders
  {
    public static StorageFolder SavedPictures { get; }
    public static StorageFolder DocumentsLibrary { get; }
    public static StorageFolder HomeGroup { get; }
    public static StorageFolder MediaServerDevices { get; }
    public static StorageFolder MusicLibrary { get; }
    public static StorageFolder PicturesLibrary { get; }
    public static StorageFolder RemovableDevices { get; }
    public static StorageFolder VideosLibrary { get; }
    public static StorageFolder ApplicationIndexedContent { get; }
    public static StorageFolder ApplicationSearchContent { get; }
    public static StorageFolder Playlists { get; }
    public static StorageFolder CameraRoll { get; }
  }
}

For example, the following code snippet successfully adds a new playlist to the Xbox Music app on Win8.1.

            var file = await KnownFolders.Playlists.CreateFileAsync("myPlaylist.wpl");
            await FileIO.WriteTextAsync(file, @"<?wpl version=""1.0""?>
<smil>
      <head>
        <title>My Playlist</title>
    </head>
    <body>
        <seq>
            <media src=""C:\Users\Justin\Music\brobob.mp3""/>
        </seq>
    </body>
</smil>");

 

After we run this code snippet and open Xbox Music Playlists we can see our new playlist:

2013-05-14_21-09-24

 

Jump back to table of contents  

XAML/WinJS: new SearchBox control

Win8 apps were encouraged to use the Search Charm for any in-app searching. However, many consumers don’t have any idea the search charm even exists. Microsoft seem to have recognized that trend and provided developers with an inline SearchBox control.

Windows.UI.Xaml namespace SearchBox class diagram 

It’s curious that SearchBox API doesn’t offer a way of entering a list of terms to search. Which either means it’s either just a plain-old-box-of-searching or it automatically hooks up to the Search Contract. Either way in-app searching without using the Search Charm will be a big UX boost for most users.

We can use the SearchBox control either from XAML or HTML. Here’s how to use it in WinJS:

<div data-win-control="WinJS.UI.SearchBox"  data-win-options="{ placeholderText  : 'place holder', }"></div>

And when we run this code snippet we can see how the SearchBox looks like with placeholder text and when it’s focused:

2013-05-14_21-27-08

 

Jump back to table of contents  

XAML/WinJS: Hubs for SemanticZoom

In Win8 coding a UI to support Semantic Zoom was a fairly painful experience. Win8.1 introduces the Hub and HubSection controls to make it easier. The Hub control is essentially a zoomed out view of a Semantic Zoom list. There’s a great screenshot on MSDN that shows the expected difference in UI between zoomed-in state and zoomed-out:

print screen from MSDN showing zoomed-in vs. zoomed-out state

Using the new Hub and HubSection controls we can easily build a UI like the zoomed out UI above. Here’s the WinJS code:

    <div data-win-control="WinJS.UI.Hub">
        <div data-win-control="WinJS.UI.HubSection" data-win-options="{header: 'Today'}">
            <div class="myItem">
                <div class="myText">32</div>
            </div>
        </div>
        <div data-win-control="WinJS.UI.HubSection" data-win-options="{header: 'Yesterday'}">
            <div class="myItem">
                <div class="myText">57</div>
            </div>
        </div>
        <div data-win-control="WinJS.UI.HubSection" data-win-options="{header: 'Last Week'}">
            <div class="myItem">
                <div class="myText">99</div>
            </div>
        </div>
    </div>

And when we run this we can see how using the Hub and HubSection controls makes building Semantic Zoom enabled UIs much easier.

2013-05-14_21-43-26

Here’s the full class diagram for the new Hub and HubSection controls:

Windows.UI.Xaml namespace Hub class diagram

 

Jump back to table of contents  

XAML: DatePicker and TimePicker

Win8 didn’t have any built-in XAML controls for DateTime selection, but did have those for WinJS. Those have been back ported to WinRT XAML API.

Windows.UI.Xaml namespace DatePicker and TimePicker class diagram

Using these controls will likely render the same UI that’s already available in WinJS for TimePicker and DatePicker controls.

WinJS rendered TimePicker and DatePicker

 

Jump back to table of contents  

XAML: Flyout, MenuFlyout and SettingsMenuFlyout

In Win8 XAML apps, it required a lot of coding to add a custom settings screen or a “hover” flyout. WinJS apps had some of that capability out of the box in Win8, but XAML apps didn’t. In Win8.1 we’ll see new XAML controls to help bridge that gap and make building hover flyouts and settings flyouts easier.

Windows.UI.Xaml namespace flyout class diagram  

The core of this API is around creating a “Flyout” (whether it’s a MenuFlyout, SettingsFlyout or a custom Flyout). MenuFlyouts can then receive MenuFlyoutItemBase that’ll allow to easily compose menus using this new APIs. Win8’s Callisto (a 3rd party project) has a similar API which probably inspired this API. Here’s a print screen from Callisto on how a Flyout could look like:

print screen from Callisto for a Flyout.

 

Jump back to table of contents  

XAML: AppBar simplification

When coding AppBar buttons in Win8 developers had to dig through approximately 100 custom styles for <Button /> to style the appbar correctly. That was a pain. WinJS on the other hand had AppBarButton with Icons that made it relatively easy to code for. Win8.1 introduces new AppBar controls that’ll make developing a XAML AppBar much easier.

Windows.UI.Xaml.Controls namespace AppBar controls class diagram

As you can see from the code diagram above the new controls include a dedicated AppBarButton, AppBarToggleButton and an AppBarSeperator. AppBarButton and AppBarToggleButton both support an “Icon” which is an instance of the IconElement class. IconElement can be practically anything: Images, XAML markup paths, built-in symbols or any font glyph.

Windows.UI.Xaml.Controls namespace AppBar icons class diagram

Here’s a code sample of how to sue the new XAML AppBar controls:

    <Page.BottomAppBar>
        <AppBar x:Name="bottomAppBar">
            <Grid>
                <AppBarButton Content="New Article">
                    <AppBarButton.Icon>
                        <SymbolIcon Symbol="Add" />
                    </AppBarButton.Icon>
                </AppBarButton>
                <AppBarSeparator />
            </Grid>
        </AppBar>
    </Page.BottomAppBar>

 

Jump back to table of contents  

XAML: DataBinding Improvements

XAML Databindings in WPF, Silverlight 4 and Windows Phone 8 have additional features that didn’t exist for Win8 and have been backported to WIn8.1. The new properties being introduces are FallbackValue, TargetNullValue and UpdateSourceTrigger. StringFormat will not be included in Win8.1. You can read more about FallBackValue and TargetNullValue on Jason's blog.

        <TextBlock Text="{Binding Path=myProperty, 
            FallbackValue='myFallbackValue', 
            TargetNullValue='myNullValue', 
            UpdateSourceTrigger=PropertyChanged}" />

Win8.1 will also introduce a DataTemplateSelector to support databinding lists to instances of multiple types and rendering different visuals for each type. More on that in MSDN.

 

Windows.UI.Xaml.Data namespace changes class diagram

 

Jump back to table of contents  

Globalization: Currencies, Numeral systems and Numerical formatters

Win8 has support to formatting dates, times and numbers based on the user’s culture. Win8.1 expands that list to support currencies, non-latin numerical systems and multiple numerical formatting functions. Each of those formatting options sounds simple before you consider the cross-cultural complexity so it’s great to see Microsoft supporting those out of the box.

Here’s an example on how Win8.1 can help our app translate to non-latin numerical systems, format currencies and help print out numbers.

    // Brazil Dollar, prints out: BZ$12345.60
    Debug.WriteLine(new CurrencyFormatter(CurrencyIdentifiers.BZD).Format(12345.6));

    // United Stats Dollar, prints out: $12345.60
    Debug.WriteLine(new CurrencyFormatter(CurrencyIdentifiers.USD).Format(12345.6));

    // Iran Rial, prints out: ????12345.60
    Debug.WriteLine(new CurrencyFormatter(CurrencyIdentifiers.IRR).Format(12345.6));

    // Arabic numerals, prints out: ??????????
    Debug.WriteLine(new NumeralSystemTranslator()
                    {
                        NumeralSystem = NumeralSystemIdentifiers.Arab
                    }.TranslateNumerals("1234567890"));

    // Thai numerals, prints out: ??????????
    Debug.WriteLine(new NumeralSystemTranslator()
                    {
                        NumeralSystem = NumeralSystemIdentifiers.Thai
                    }.TranslateNumerals("1234567890"));

    // percent formatter, prints out: 1236.789 %
    Debug.WriteLine(new PercentFormatter().Format(12.36789));

    // Permille formatter, prints out: 12367.89 ‰
    Debug.WriteLine(new PermilleFormatter().Format(12.36789));

    // Rounding formatter, prints out: 13
    Debug.WriteLine(new SignificantDigitsNumberRounder()
                    {
                        RoundingAlgorithm = RoundingAlgorithm.RoundUp,
                        SignificantDigits = 2
                    }.RoundDouble(12.3));

As we can see each language and formatting algorithm has a certain amount of complexity to it. Currency formatters change base on the currency symbol and the its location; some cultures need to format numbers in non-latin numerals; and formatting percents or rounding is also culturally specific. Having these built-in formatters is going to prove super useful to WinRT developers. Just the CurrencyFormatter alone is sure to be used by any Win8.1 app that has in-app purchase enabled for multiple markets.

 

Jump back to table of contents  

Other minor but important Win8.1 features

There are additional smaller Win8.1 features that developers might find interesting:

 

Jump back to table of contents  

How to code Win8.1 C# apps before public beta?

These instructions are only useful before BUILD 2013 conference (June 22nd 2013). After this date simply installing Win8.1 with the development tools will suffice.

Debuggin Win8.1 apps in VS2012

Here are the instructions to develop on Windows 8 with Visual Studio 2012 and deploy & debug on Win8.1:

  1. Install WIn8.1.
  2. Enable Win8 remote debugging like you would for any Win8 machine. Install Visual Studio 2012 Remote debugging tools and run them.
  3. Create a new Windows.WinMD that matches Win8.1 and could then be copied to a Win8 development machine. On your Win8.1 machine run the following command:
    mdmerge -i c:\Windows\System32\WinMetadata\ -o c:\temp\windows.winmd /n 1
  4. Backup your Win8 Windows.WinMD file so you could return to Win8.0 development if you choose to. The file is located @
    "c:\Program Files (x86)\Windows Kits\8.0\References\CommonConfiguration\Neutral\Windows.winmd"
  5. Finally replace your Win8 Windows.WinMD file with the Win8.1’s Windows.WinMD file.
  6. Restart VS2012 and you can now code against Win8.1 APIs on Win8, deploy to a Win8.1 machine and debug. 

 

Jump back to table of contents  

How to develop Win8.1 WinJS apps before public beta?

These instructions are only useful before BUILD 2013 conference (June 22nd 2013). After this date simply installing Win8.1 with the development tools will suffice.

Debugging WinJS 2.0 apps in VS2012

In order to code, deploy and debug Win8.1 WinJS apps from Win8 and Visual Studio 2012 follow these steps:

  1. Find WinJS 2.0 files from your local  C:\Program Files\WindowsApps folder. You’ll need to do some fancy security permission changes and then you’ll be able to copy “Microsoft.WinJS” folders.
    Or you can download a copy from @ http://justinangel.net/storage/windows81/WinJS2.0Preview.zip
  2. Create a new Win8 WinJS project in Visual Studio 2012.
  3. Add copies of ui.js, base.js and ui-light.css to your project from the aforementioned folders.
  4. Replace all references to ui.js, base.js and ui-light.css with references to your locally embedded files.
  5. You can now code against WinJS 2.0 APIs on a Win8 machine, and run & debug on Win8.1.

 

Jump back to table of contents  

Disclaimer: Please don’t sue me

The article is written to share original research on the upcoming WinRT goodness with other developers. I have no insider information what-so-ever on Windows 8.1.

This article compromises my personal conclusions from “leaked” Windows 8.1 OS Images. No NDAs were harmed in the making of this article. I do not have and never had any pre-release access to WIndows 8.1 provided to me by Microsoft or anyone else. This article was written and researched on my own time and has no affiliation with my employer. 

 

Feedback?

Questions? Feedback? Other insights? Sound off in the comments.

 

Sincerely,
-- Justin Angel



Comments