Skip to content

Instantly share code, notes, and snippets.

@pedrolamas
Created August 7, 2014 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrolamas/6885697597d686b5f399 to your computer and use it in GitHub Desktop.
Save pedrolamas/6885697597d686b5f399 to your computer and use it in GitHub Desktop.
Grid layout in WP8.1
/*
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