简体   繁体   中英

Entry control in Xamarin.Forms app not full length in StackLayout

I'm starting out with Xamarin.Forms and I'm trying to create the following Login/Password xaml form:

<StackLayout Orientation="Vertical">

    <StackLayout Orientation="Horizontal">
        <Label ClassId="lblUserID" Text="User ID: " FontAttributes="Bold" TextColor="Red"></Label>
        <Entry ClassId="txtUserID" BackgroundColor="White" ></Entry>
    </StackLayout>
    <StackLayout Orientation="Horizontal">
        <Label ClassId="lblPassword" Text="Password: " FontAttributes="Bold" TextColor="Red"></Label>
        <Entry ClassId="txtPassword" BackgroundColor="White" ></Entry>

    </StackLayout>

</StackLayout>

When I try to view the page in the Forms Previewer inside Visual Studio 2015, I'm noticing the entry controls are only showing a small width as opposed to my desired effect of showing on the rest of that row. I've tried tinkering around with WidthRequest and MinimumWdithRequest, but that doesn't seem to be the right property. Is there a special property that needs to be set in order for the entry controls to display full row (or at least as much of the row as possible)?

Thanks!

You will need to set the HorizontalOptions to

HorizontalOptions="FillAndExpand"

This will cause the control to fill the remaining space on the screen.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM