What Happened to My LayoutAwarePage?

Recently at the //Build/ Conference Microsoft showed off the development environment for Windows 8.1.  In less than an year Microsoft has rev’ed Visual Studio.  For Windows 8, Microsoft tried to provide project templates that got you heading in the right direction.  If you did File-> New Project and you chose the Grid App template you got a solution explorer that looks like this:

Solution Explorer VS 2012

One of the first thing people noticed was that all the xaml pages inherited LayoutAwarePage.cs.  In Windows 8 an application could be in a coupled of different states, Filled, Full, Snapped (320px).  The LayoutAwarePage took care of setting the ViewStateManager to the appropriate state.  It also took care of maintaining state in the case of app suspension. At first this class confused some people, myself included.  So I did a post about it, What is This ‘LayoutAwarePage’ You Speak Of

Fast forward to today.  Fire up Visual Studio 2013 and choose the same template.  Your solution explorer now looks like this:

Solution Explorer VS 2013

No more LayoutAwarePage, no more StandardSyles.xaml and a few other changes.  Where did that LayoutAwarePage  go?  Well in Windows 8.1 there is no hard and fast starts that the application has to fit in.  The developer sets a minimum size and the user can choose any size above that minimum size. This was one of the improvements that was made in 8.1. With that the user can have more than two apps going at the same time.

Multi-Snap Screen Shot

Now that you can have variable sized windows, the killed the ApplicationViewState enumeration.  Developers will now have to determine at which size, the view state of their application should change.  If you used the ApplicationViewState enumeration, you will have some refactoring to do. With this change they did away with the LayoutAwarePage.  So the LayoutAwarePage was also responsible for state management during the application life cycle events.  What happen to that?

There is a new NavigationHelper class to handle that.  In the Solution Explorer you will now see NavigationHelper.cs in the common folder. If you read the comments at the top of the class, you get some instructions on how to use it.

NavigationManager aids in the navigation between pages.  It provides commands used to navigate back and forward as well as registers for standard mouse and keyboard shortcuts used to back and forward.  In addition it integrates SuspensionManager to handle process lifetime management and state management when navigating between pages.

I have not had a chance to take a real good look at what this class is doing, so I don’t know if I will use it as is, modify it, or create a different paradigm.

Another file that is missing is the StandardStyles.xaml.  These styles still exist. They are just baked into the generic.xaml for the controls. You can access those through  the new xaml intellisense feature and you can override those styles to apply your own.

One more change that I want to point out can be found in the Add New Project Dialog.

New Project Dialog

Notice the two new templates.  There is a new Hub App template and the new Coded UI test Project. The Hub App template is similar to the Grid App but it makes it easier to create groups of items, think the Windows 8 new application.  The other template lets you create Coded UI tests.  Microsoft has made some improvements in xaml to allow for UI testing.  These changes have helped made Automated UI testing possible.  I haven’t had a chance to look at all the changes made but when I do I will report on what I find.

These templates provide a great starting point for your projects.  It is hard not to believe that future changes will not break what they have done.  My advice is to use the new files as a template to creating your own implementation.  This is what I did with the LayoutAwarePage and I am glad that I did.  This should help make refactoring easier in the future.  I am  excited to take the new features for a spin.  Stay tuned!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: