我从 Xamarin.Forms 开始,尝试创建以下登录/密码 xaml 表单:
<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>
当我尝试在 Visual Studio 2015 内的表单预览器中查看页面时,我注意到条目控件仅显示很小的宽度,而不是我想要的在该行的其余部分显示的效果。我尝试修改 WidthRequest 和 MaximumWdithRequest,但这似乎不是正确的属性。是否需要设置一个特殊属性才能使条目控件显示整行(或至少尽可能多的行)?
谢谢!
最佳答案
您需要将 HorizontalOptions 设置为
HorizontalOptions="FillAndExpand"
这将导致控件填充屏幕上的剩余空间。
关于c# - Xamarin.Forms 应用程序中的条目控件在 StackLayout 中不是完整长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42707475/