Friday 24 August 2012

PointerOver visual state on WinRT, it’s over even if it’s not.

I’ve been trying to get my Bridge Stenographer App ported to Windows 8 and in the process have come across a few problems.  The latest being that I click on a button on the welcome page to get somewhere else in the app, and when I navigate back, my button is still in the pointer over state, despite the pointer being elsewhere.

I’ve tracked this down to using  NavigationCacheMode="Required" on the page, in order to keep my page alive.

As a result, when I navigate back to the page, the controls don’t get whatever the equivalent of MouseLeave is, and therefore don’t transition out of the PointerOver state, and this doesn’t just apply to Buttons.  Combo boxes have this behavior as well.

You’ve been warned.

1 comment:

  1. Hi, I found your post earlier today ( http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/32b12df0-f132-43cf-a675-51832e7186fb/ ) and then I found this blog post a bit later. I had the same problem but I did manage to fix the problem using the VisualStateManager as was suggested by one of the posters on MSDN Social. The trick was to put the line in the Loaded event for the page.

    private void pageRoot_Loaded(object sender, RoutedEventArgs e)
    {
    VisualStateManager.GoToState(backButton, "Normal", false);
    }

    ReplyDelete