框架内的Xamarin表单标签未显示

问题描述 投票:0回答:2

我有问题。我使用以下代码在页面中创建了一个框架:

<Grid BackgroundColor="#212121">

    <Grid.RowDefinitions>
        <RowDefinition Height="50" />
        <RowDefinition Height="*" />
        <RowDefinition Height="50" />
    </Grid.RowDefinitions>


    <Grid Grid.Row="1" Margin="20, 0, 20, 0">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="50" />
            <RowDefinition Height="50" />
            <RowDefinition Height="50" />
            <RowDefinition Height="30" />
            <RowDefinition Height="50" />
            <RowDefinition Height="40" />
            <RowDefinition Height="40" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Image Source="Logo.png" HeightRequest="200" VerticalOptions="End" Margin="30" />
        <Entry Grid.Row="1" Placeholder="Username" PlaceholderColor="#bababa" FontSize="16" x:Name="txtUsername" TextColor="White" />
        <Entry Grid.Row="2" Placeholder="Email" PlaceholderColor="#bababa" FontSize="16" x:Name="txtEmail" TextColor="White" />
        <Entry Grid.Row="3" Placeholder="Password" PlaceholderColor="#bababa" FontSize="16" IsPassword="True" x:Name="txtPassword" TextColor="White" TextChanged="OnPasswordTextChanged" />

        <Frame Grid.Row="4" BackgroundColor="Transparent" BorderColor="Transparent" x:Name="FramePasswordStrength" >
            <Label Text="Test" BackgroundColor="Purple" TextColor="White" HorizontalOptions="Center" VerticalOptions="Center" x:Name="txtPasswordStrength" FontSize="14" />
        </Frame>

        <Entry Grid.Row="5" Placeholder="Confirm Password" PlaceholderColor="#bababa" FontSize="16" IsPassword="True" x:Name="txtConfirmPassword" TextColor="White" />
        <Button Text="Sign up" FontAttributes="Bold" Clicked="btnRegisterClicked" BackgroundColor="#3897F0" TextColor="White" HeightRequest="50" VerticalOptions="Start" Grid.Row="6" />
    </Grid>
</Grid>

问题是我的框架以我想要的方式绘制,但是该框架的中心没有标签。现在,我已经尝试减小FontSize,但这是行不通的。

我在做什么错?

xamarin xamarin.forms xamarin.android xamarin.ios
2个回答
1
投票
尝试将<RowDefinition Height="Auto" />设置为行的高度,以便它对所有控件都具有正确的高度。

0
投票
实际问题是帧的默认填充为20,以将其子元素显示为帧效果。要解决您的问题,请调整填充。
© www.soinside.com 2019 - 2024. All rights reserved.