Windows Store Applications allow the user to change the size of the application and change the the layout to e vertical or horizontal.
in order to provide god user experience we want adapt our view to different modes. For instance, showing a grid like view when in Full Horizontal mode and change it a List when we are snapped to side (and look vertical).
The examples and guidelines on how to change your view based on the page layout change are around those option:
- In your page XAML write the representation for both mode and change visibility based on the current mode
- Use VisualStyleManager in your page and change your controls properties based on the current mode
My coworker Noam Gindi and I felt that this is not ideal and starteted to look for a more elegent way
I wanted to take advantage of Caliburn.Micro View.Context
So what we did was creating a base ResizablePage that knows how to change the View.Context according to the page dimensions. since Caliburn.Micro Binds the ViewModel to the Page it will automatically switch the inner view according to the context.
in our case we set a convention that the the view will be suffixed with “SnapView” or “FullView”
This is the ResizalePage code:
and now you simply need to derive your page from it and create the inner view for the two cases mentioned above.