Created
August 7, 2014 13:02
-
-
Save pedrolamas/6885697597d686b5f399 to your computer and use it in GitHub Desktop.
Grid layout in WP8.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
In the "old" Windows Phone grid layout you would have a two columns layout like so: | |
MMCMCMM | |
where M is a 12px margin and C is the column width (so 5 * M + 2 * C = Width) | |
For a 3 columns layout it would be: | |
MMCMCMCMM | |
where M is a 12px margin and C is the column width (so 6 * M + 3 * C = Width) | |
So I created two double resources and calculate the value of C in app startup! | |
In app.xaml.cs after creating and settings the RootFrame I added the following: | |
*/ | |
Resources["TwoColumnsGridTileDimension"] = (Window.Current.Bounds.Width - 48) / 2; // 48 = 9.6 * 5 | |
Resources["ThreeColumnsGridTileDimension"] = (Window.Current.Bounds.Width - 57.6) / 3; // 57.6 = 9.6 * 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment