locked
Center frame in a tablet screen RRS feed

  • Question

  • User390270 posted

    How to have a frame centered in the screen. The frame will have only a Label, an Entry of maximum 6 numbers width and a button.

    Friday, November 8, 2019 10:58 PM

Answers

  • User382871 posted

    Add a StackLayout in Frame, set HorizontalOptions and VerticalOptions to CenterAndExpand to center the content. <Frame BackgroundColor="LightBlue"> <StackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"> <Label Text="Frame content"/> <Entry MaxLength="6"/> <Button /> </StackLayout> </Frame>

    Tutorial: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/frame

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, November 11, 2019 2:31 AM

All replies

  • User382871 posted

    Add a StackLayout in Frame, set HorizontalOptions and VerticalOptions to CenterAndExpand to center the content. <Frame BackgroundColor="LightBlue"> <StackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"> <Label Text="Frame content"/> <Entry MaxLength="6"/> <Button /> </StackLayout> </Frame>

    Tutorial: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/frame

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, November 11, 2019 2:31 AM
  • User390270 posted

    Thank you.. I am new to Xamarin and I do not know why it gets the width of the whole screen in my attempts. Your answer is very simple and helped me.

    Wednesday, November 13, 2019 6:56 PM