0

Not sure if this is the right place to be asking this. I'm also not sure if I'm just bad at the internet, but I haven't been able to find any definitive documentation on Xamarin's UI Coordinate System. I can tell that (0, 0) is top left. However, is the origin for UI objects in the center? Is it on the top left; middle left? The system is obviously not gauged in pixels. Are absolute positions resolution independent?

If any one knows of this documentation / can give me a detailed explanation of how this works I would be eternally grateful.

Thanks in advance!

user1311199
  • 119
  • 1
  • 1
  • 9

1 Answers1

0

All sizes all calculated from top left of their parent. The root parent is Page.

How things are positioned also depends of LayoutOptions (https://stackoverflow.com/a/25338534/5064986)

Xamarin.Forms has a philosophy of using the conventions of the underlying platforms as much as possible. In accordance with this philosophy, the Xamarin.Forms programmer works with sizes defined by each particular platform. All sizes that the programmer encounters through the Xamarin.Forms API are in these platform-specific device-independent units.

That would be "points" in iOS and "dpi" on Android.

There's a whole book chapter about it (free) https://download.xamarin.com/developer/xamarin-forms-book/BookPreview2-Ch05-Rel0203.pdf

Community
  • 1
  • 1
Daniel Luberda
  • 7,374
  • 1
  • 32
  • 40
  • Does this remain the same when you're working in a cross-platform solution? much of the UI is laid out once in the main solution rather than the platform specific solutions. It will use the same value for each UI object's bounds when deploying to iOS or Android. So if I were to set the width of a Grid column to 50 would it still be 50 points when I released for iOS and 50 dpi when I released for Android? There is no guarantee that 1 point == 1 dpi, yet the grid column's width is the same on both platforms. How does this work? – user1311199 Sep 16 '15 at 17:07
  • Yes, it does work the same in any Xamarin.Forms app. There's no guarantee that 1 point == 1 dpi, but most time it's quite similar in size. – Daniel Luberda Sep 21 '15 at 14:49