c# - Xamarin.Forms 应用程序中的条目控件在 StackLayout 中不是完整长度

标签 c# xaml xamarin.android xamarin.forms

我从 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,但这似乎不是正确的属性。是否需要设置一个特殊属性才能使条目控件显示整行(或至少尽可能多的行)?

谢谢!

最佳答案

您需要将 Horizo​​ntalOptions 设置为

HorizontalOptions="FillAndExpand"

这将导致控件填充屏幕上的剩余空间。

关于c# - Xamarin.Forms 应用程序中的条目控件在 StackLayout 中不是完整长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42707475/

相关文章:

c# - 将 ListBox 放入 ScrollViewer : mouse wheel does not work

c# - 使用一个 DependencyProperty 在 UserControl 中绑定(bind)具有多个属性的模型

xamarin - 应用程序不会部署到 Android,但会编译

c# - 一次性方法的单元测试

C# 为结构错误的属性赋值

c# - 如何根据当前主题更改 MahApps.Metro 进度条颜色?

ssl - 从类中使用 Xamarin Android HttpClient 错误

c# - EF 核心数据库特定列到嵌套对象

c# - 使用 TabControl 和 MVVM 在 WPF 中正确进行数据绑定(bind)

Android AudioRecord StartRecording - 应用挂起