[Cross-posted from blog.davemdavis.net]
Recently at the //Build/ Conference Microsoft showed off the development environment for Windows 8.1. In less than a 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:
One of the first things people noticed was that all the XAML pages inherited LayoutAwarePage.cs. In Windows 8 an application could be in a couple of different states, for example Filled, Full, and 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:
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 state 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.
Now that you can have variable sized windows, they 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 in a previous build, 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 happened 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 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 now 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.
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 make Automated UI testing possible. I haven’t had a chance to look at all the changes but when I do I will report on what I find.
These templates provide a great starting point for your projects. It is hard to believe that future changes will not break what they have done. My advice is to use the new files as a template to create 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!