【发布时间】:2020-06-10 01:36:00
【问题描述】:
我在 XAML 中创建了一个框架,其中包含表单。正如您在下面看到的,用户需要从中选择 3 个 Picker 字段。但是,只有第一个有效。
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="LoanApp2.Views.LoanApplication"
Title="Title"
Shell.NavBarHasShadow="False"
>
<ContentPage.ToolbarItems>
<ToolbarItem IconImageSource="icon_dropdown.png"/>
</ContentPage.ToolbarItems>
<!--Root Grid -->
<Grid>
<!-- Root Grid definitions -->
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Blue frame -->
<Frame Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="2" Padding="0" BackgroundColor="#62bef0" HasShadow="False">
<!-- Contains loan history text and desc -->
<StackLayout Grid.Row="1">
<Label Text="LOAN APPLICATION" FontSize="30" VerticalOptions="Center" FontAttributes="Bold" TextColor="White" HorizontalOptions="Center"/>
</StackLayout>
</Frame>
<!-- Contains form -->
<StackLayout Grid.Row="1" Grid.ColumnSpan="3" Orientation="Vertical">
<Frame BackgroundColor="White" Margin="30, 20, 30, 0" Padding="30" CornerRadius="5">
<StackLayout Orientation="Vertical">
<Label Text="Lorem ipsum dolor sit amet, consectetur." TextColor="#62bef0" HorizontalTextAlignment="Center"/>
<Picker Title="Select Loan Type...">
<Picker.Items>
<x:String>Lorem ipsum</x:String>
<x:String>dolor sit amet</x:String>
<x:String>consectetur</x:String>
</Picker.Items>
</Picker>
<Picker Title="Select Loan Class...">
<Picker.Items>
<x:String>adipiscing elit</x:String>
<x:String>Nam gravida mauris</x:String>
<x:String>a velit rhoncus</x:String>
</Picker.Items>
</Picker>
<Picker Title="Select Purpose...">
<Picker.Items>
<x:String>tempor porta vitae</x:String>
<x:String>Nullam ultrices</x:String>
<x:String>aliquam</x:String>
</Picker.Items>
</Picker>
</StackLayout>
</Frame>
</StackLayout>
</Grid>
</ContentPage>
上面的结构是 StackLayout > Frame > StackLayout > Pickers - 只有第一个选择器有效
我尝试尝试将第二个 StackLayout 的方向设置为水平,所有选择器都可以正常工作,但这不是我想要实现的外观。
我尝试了 StackLayout > Pickers 之类的结构 - 一切正常,但我需要将选择器包装在一个框架中以用于 UI 目的。 StackLayout > Frame > Pickers 没有提供所需的输出。
【问题讨论】:
-
您的网格可能有问题,您可以发布完整的网格吗?
-
@Adlorem 我已经添加了完整的代码。谢谢。
-
正如@Adlorem 在
Grid中提到的一个问题。将Grid.RowSpan = 4设置为StackLayout覆盖Picker。或更改RowDefinitions。检查它是否有帮助。
标签: xaml xamarin.forms