Forum Xamarin.Forms

Get TitleView to resize when window resizes

We have a TitleView with a centered title and a StackLayout that is supposed to hug the right side of the page. This works fine until the page gets resized, because the right-side buttons don't move. How do I get the TitleView to refresh/update in this situation?

Best Answer


  • LandLuLandLu Member, Xamarin Team Xamurai

    Which scenario will your page get resized?
    I tested with a simple title view like:

        <StackLayout Orientation="Horizontal">
            <Button Text="button" HorizontalOptions="EndAndExpand"/>

    I changed the rotation on iOS and Android and the size on UWP but the button always aligns at the right side without any problems.
    Could you please specify your circumstances and share your code here.

  • MigdalinMigdalin Member ✭✭
    edited September 2019

    I see now that we are using a custom control that's called NavigationTitleView, but is actually a Grid with three StackLayouts inside it, one for left, middle, and right. The right-side StackLayout uses HorizontalOptions="End." I tried it with EndAndExpand, but that had no effect. The owning page, in turn, is the details portion of a master-detail page. Maybe I can hook into the resize event of the owning page?

    One problem is that the Parent property on the Grid is null. That makes it hard to hook into the page's resize.

  • MigdalinMigdalin Member ✭✭

    Our custom title view Grid is actually wrapped inside the normal TitleView. Unfortunately, it looks like resize events aren't getting propagated down, so the Grid isn't updating when the page changes size. Could be this is only an issue under UWP, since it's only orientation changes that affect the other two platforms.

Sign In or Register to comment.