locked
how to refresh a page RRS feed

  • Question

  • User292885 posted

    I have a xaml page that sizes a bunch of stuff (grid) when it first renders, depending on screen width. But if the user rotates, the sizing is all wrong. I can detect rotation using OnSizeAllocated, but how do I get the page to refresh itself to resize the grid columns?

    Monday, June 18, 2018 5:18 PM

Answers

  • User180523 posted

    I'd pretty much say "Stop - You're way off already"

    If you're manually micromanaging the size of everything my guess is you're coming to Xamarin from Windows Forms circa 1998 where that was the kind of thing you had to do. But these days (as in for the last 10-ish years) we really just don't do that sort of thing.

    A good XAML layout will resize dynamically if you keep everything in generic, relative terms. Column 1 is 2star wide... Column 3 is 5star wide and so on.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, June 18, 2018 5:55 PM
  • User344025 posted

    A good way to ensure sizing consistencies is to avoid anything that is "absolute".

    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/grid#spacing

    This link goes into the spacing for grid layouts and setting the width to "*" allows for relative layout, whether you change the orientation or not, the layout should look (relatively) the same.

    The asterisk can be placed any number of times in the Grid, which means that each row or column will be proportionally sized.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, June 18, 2018 7:02 PM

All replies

  • User180523 posted

    I'd pretty much say "Stop - You're way off already"

    If you're manually micromanaging the size of everything my guess is you're coming to Xamarin from Windows Forms circa 1998 where that was the kind of thing you had to do. But these days (as in for the last 10-ish years) we really just don't do that sort of thing.

    A good XAML layout will resize dynamically if you keep everything in generic, relative terms. Column 1 is 2star wide... Column 3 is 5star wide and so on.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, June 18, 2018 5:55 PM
  • User292885 posted

    I will give that a try again.

    Monday, June 18, 2018 6:59 PM
  • User344025 posted

    A good way to ensure sizing consistencies is to avoid anything that is "absolute".

    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/grid#spacing

    This link goes into the spacing for grid layouts and setting the width to "*" allows for relative layout, whether you change the orientation or not, the layout should look (relatively) the same.

    The asterisk can be placed any number of times in the Grid, which means that each row or column will be proportionally sized.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, June 18, 2018 7:02 PM