This is extremely frustrating. Business need is simple. I need 6 images evenly spaced in a row across the screen which auto size keeping their aspect ratio to fill the screen regardless of device.
Kind of the whole point of a grid right? Create a Grid add 6 columns set their widths to"*" and boom done!
Not so much. As has been ignored in another couple posts when you do this the height of the row is scaled to whatever the image height was before it was scaled to fit the grid and you end up with an unacceptable amount of white space both above and below.
Can't use one of the image's SizeChanged Events to set the Grid HeightRequest to the height of the image because that will cause the grid to resize which will fire the size change and loop de loop you go and your app crashes. Put some logic in so it doesn't update the grid unless the sizes are different...still crashes in Xamarin code I can't get to.
What about using a SizedChange event from something further down the page? Now we don't have a loop, but Xamarin doesn't consistently build the page out in any sort of order. Result of testing are sometimes the grid will size right, and sometimes the height will be nothing because the image within the grid hasn't rendered yet.
Can't use OnAppearing because the image hasn't rendered yet and so we don't know it's size. There is no event that fires after the page has drawn so I can't use something that doesn't exist.
Binding the Grids Height request to the Image's Height via x:Reference does nothing; this trick is something I've used on WinRT XAML to force things to scale proportionally but no luck here.
Sure I can just set a height on the Grid's Row but now I'm not meeting the business requirement. The images are no longer scaled to the device.
Can't use a stacklayout set to horizontal, it just fits whatever it can on the screen and depending on the screen images run off it.
How do you all manage to write apps that scale properly? Do I really have to use something in OnAppearing to get the width of the device and then fun math to figure out how big each item should be? Cause if I have to do that, what is the point of a Grid?
Thanks to anyone with a solution.