Improve the usability of search in your Windows Style App

When your app could do with the search feature, implement it. But something that’s even more important is the discoverability of search. Not everyone knows how use the charms bar, or doesn’t want to use the charms. When you just start typing in the Store app it starts immediately showing the search pane with the input characters. I suggest you do the same when your apps supports search. How?

One line of code in your App OnLaunched method, I added it just after Window.Current.Activate().

// Show search on keyboard input.
SearchPane.GetForCurrentView().ShowOnKeyboardInput = true;


I know this is a very short post, but the API was pretty unknown to me until I tried it myself.

Update 23-01-2013:

Chris Veeningen (@Bloodyairtimer) explained to me that this should only be used on read-only views. So if you instead have an input box in your view this won’t work. So instead you could put the above line of code in the OnNavigatedTo method of your readonly views. I would also set it to false in the OnNavigateTo method of the views that contains input fields. Hope this helps a bit.

Searching a database solution for Windows Phone 7-8 and for Windows 8

I’m preparing for one of my new app-ideas. This app-idea requires a local storage of data, initially I want to create this app for Windows Phone, but I would like to have as much code-reuse as possible. So it would be very nice to have the same database solution for all platforms.

I’ve been using Sterling in the past for Windows Phone. This was before SQL CE was available for Windows Phone. Looking at releases, the last release of Sterling is from June 2011, more than a year and half ago. When I’m looking at the Source Code I’m seeing an resume in commits in last December. So the project is not dead, at least it doesn’t look dead to me. There’s also a discussion on the Future of Sterling which might interest you. There seems to be an issue with Windows Phone 8 which you can easily patch yourself. Okay, interesting, but there is no solution for Windows 8 apps yet.

Let’s explore the other options. SQL CE was added to Windows Phone 7 during one of the updates. However it’s not added to Windows 8 and will probably not be added to Windows 8 because there has been a lot of talking about SQLite in the area of Windows 8. But for Windows Phone 8 SQL CE seems to be lacking and there’s an option to use SQLite for Windows Phone 8 as well. So definitely no SQL CE for me, I want to have a solution that works at least for the whole Phone platform and not just the Windows Phone 7 platform.

So there’s a lot of talking about SQLite? It does support Windows 8 and Windows Phone 8 apps. After some searching there isn’t any official support for Windows Phone 7. I found an article written in 2011 that might help get SQLite on Windows Phone 7. This is an almost solution, maybe I just need to give SQLite a try.

While browsing the Sterling discussions I came around a comment about Lex.DB. This might be an interesting alternative, but it doesn’t support Windows Phone 7 yet. I’ll keep an eye on this project, but it’s very new in this space.

Update 26-01-2013:

In the comments Marcio already says that SQL CE works fine on Windows Phone 8. So even while there isn’t much to be found on that subject it should work. I had to try this myself, so I did. And the end-result? Windows Phone 8 supports SQL CE very well, nothing special that I’ve found in there so far.

Getting useful Device Information for Analytics

When I’m looking at the Analytics I’m doing for my Windows Phone apps there are quite a couple of things I’m registering. All anonymous of course, but I’d like to know things about the devices the users of my apps are using. So I went looking for a way to get the same information I already register for my Windows Phone Apps in Google Analytics (see my useful nuget package to get Google Analytics in your Windows Phone apps).

I already have the application version, I explained how to get it in an earlier post. Further more I try to register: Device Manufacturer, Device Type and OS Version. Though the OS Version doesn’t make that much sense I think.

var deviceInfo = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();
var manufacturer = deviceInfo.SystemManufacturer; //Output: Dell Inc.
var productName = deviceInfo.SystemProductName; //Output: Dell System XPS L702X

That was easy, but getting this information through the Exchange Active Sync classes sounds strange, it works and that is what matters. If you know any alternative solutions please add your comments.

I also would like to know the resolution of the user. My current thoughts are that they are probably very high for non-tablets, but the tablets are probably 1366x768. You can get information about the screen-size through Windows.Current.Bounds, however be carefull, the Width is different when the app is snapped or fill mode.

var deviceWidth = Window.Current.Bounds.Width;
var deviceHeigth = Window.Current.Bounds.Height;

Alright that’s very interesting information so far. Maybe this would be useful for a port of the Google Analytics package to support Windows 8 apps.

TechDays 2013 - Make your Windows 8 app stand out


After attending the Dutch TechDays for quite a couple of years, only last year I wasn’t able to attend. But I’m back this year, not as an attendee but as a speaker. It’s a dream coming true!

The session will be in Dutch, so only the Dutch description makes sense, sorry. You can find my session here.

Make your Windows 8 app stand out

  • Windows 8 heeft een enorm bereik en kan veel voor je app betekenen. Hoe zorg je ervoor dat je app opvalt binnen de zee van applicaties in de Store? Deze sessie gaat in op hoe je optimaal gebruik kunt maken van de mogelijkheden die Windows 8 biedt, zoals:
    - Full, Snap en Fill views
    - Share contract
    - Search contract
    - Play to contract
    - Semantic zoom
    - Tiles en toast
    - Offline mode
    - Touch, Mouse en Keyboard
    Maak ook gebruik van het potentieel van de Windows Store, door middel van reviews, en marketing materiaal en verschillende verdienmodellen zoals trials, in-app purchases of advertenties.

Navigation through your Windows Style app

I was navigating through the code I found inside the default project templates that are available for Windows Style apps. They already contain a lot of plumbing, specially around navigating through pages.

While reading the LayoutAwarePage.cs I found some code that handles keystrokes. I even found out something I did not know.

- Navigate backward in an app using Alt+Left
- Navigate forward in an app using Alt+Right

But strangely, I’m using to navigate backward using the Backspace key, this was not in the default LayoutAwarePage.cs code. But when you for example use the Store app navigating backward using the Backspace key will work. So let’s improve the default LayoutAwarePage to support the Backspace key as well. Just add the highlighted code to the CodeDispatcher_AcceleratorKeyActived method inside the LayoutAwarePage.cs.

/// <summary>
/// Invoked on every keystroke, including system keys such as Alt key combinations, when
/// this page is active and occupies the entire window.  Used to detect keyboard navigation
/// between pages even when the page itself doesn't have focus.
/// </summary>
/// <param name="sender">Instance that triggered the event.</param>
/// <param name="args">Event data describing the conditions that led to the event.</param>
private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender,
                                                    AcceleratorKeyEventArgs args)
    VirtualKey virtualKey = args.VirtualKey;

    // Only investigate further when Left, Right, or the dedicated Previous or Next keys
    // are pressed
    if ((args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
            args.EventType == CoreAcceleratorKeyEventType.KeyDown) &&
        (virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right ||
            (int) virtualKey == 166 || (int) virtualKey == 167))
        CoreWindow coreWindow = Window.Current.CoreWindow;
        var downState = CoreVirtualKeyStates.Down;
        bool menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
        bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
        bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;
        bool noModifiers = !menuKey && !controlKey && !shiftKey;
        bool onlyAlt = menuKey && !controlKey && !shiftKey;

        if (((int) virtualKey == 166 && noModifiers) ||
            (virtualKey == VirtualKey.Left && onlyAlt))
            // When the previous key or Alt+Left are pressed navigate back
            args.Handled = true;
            this.GoBack(this, new RoutedEventArgs());
        else if (((int) virtualKey == 167 && noModifiers) ||
                    (virtualKey == VirtualKey.Right && onlyAlt))
            // When the next key or Alt+Right are pressed navigate forward
            args.Handled = true;
            this.GoForward(this, new RoutedEventArgs());
    if((args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
            args.EventType == CoreAcceleratorKeyEventType.KeyDown) && args.VirtualKey==VirtualKey.Back)
        args.Handled = true;
        this.GoBack(this, new RoutedEventArgs());