Xaml stacklayout中带有imagecell的Listview上的高度

Xaml stacklayout中带有imagecell的Listview上的高度,xaml,listview,xamarin,xamarin.forms,frame,Xaml,Listview,Xamarin,Xamarin.forms,Frame,我有个问题。我在Listview中有一个imagecell,在一个框架中,我将所有内容都放在stacklayout中。 我的问题是带有imagecell的框架的高度太高。现在,我只在里面有两个项目,但高度就像页面的大小 XAML代码: <AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"> <StackLayout AbsoluteLayout.LayoutF

我有个问题。我在Listview中有一个imagecell,在一个框架中,我将所有内容都放在stacklayout中。 我的问题是带有imagecell的框架的高度太高。现在,我只在里面有两个项目,但高度就像页面的大小

XAML代码:

 <AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
    <StackLayout AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1">
        <ScrollView>
            <StackLayout Padding="10,20,10,10">
              <Frame x:Name="frameOpcoes"  OutlineColor="Gray" HasShadow="True" VerticalOptions="Fill" HorizontalOptions="FillAndExpand" BackgroundColor="White">
                    <StackLayout Padding="0,10,0,0" Orientation="Vertical">
                        <StackLayout Orientation="Horizontal"  HorizontalOptions="FillAndExpand">

                            <StackLayout Orientation="Vertical"  HorizontalOptions="Start">
                                <Label x:Name="lblOpcoes" Text="Placa: " TextColor="Gray" FontAttributes="Bold"/>
                            </StackLayout>

                            <StackLayout Orientation="Vertical"  HorizontalOptions="FillAndExpand">
                                <Entry x:Name="entryPlacaLetra" TextChanged="entryLetra_TextoAlterado" Keyboard="Text"  TextColor="Black" BackgroundColor="#D3D3D3" />
                            </StackLayout>

                            <StackLayout Orientation="Vertical"  HorizontalOptions="Fill">
                                <Label x:Name="lblTraco" Text="-" TextColor="Gray" FontAttributes="Bold"/>
                            </StackLayout>

                            <StackLayout Orientation="Vertical"  HorizontalOptions="FillAndExpand">
                                <Entry x:Name="entryPlacaNum" TextChanged="entryNum_textoAlterado" Keyboard="Numeric" TextColor="Black" BackgroundColor="#D3D3D3"/>
                            </StackLayout>

                        </StackLayout>

                        <StackLayout VerticalOptions="FillAndExpand">
                            <ListView x:Name="listView" HorizontalOptions="FillAndExpand" VerticalOptions="Start" HasUnevenRows="True" SeparatorVisibility="None">
                                    <ListView.ItemTemplate>
                                        <DataTemplate >
                                            <ImageCell Text="{Binding Title}" Detail="{Binding Detail}" DetailColor="Gray" TextColor="Black" ImageSource="{Binding IconSource}" />
                                        </DataTemplate>
                                    </ListView.ItemTemplate>
                                </ListView>
                        </StackLayout>

                    </StackLayout>
                </Frame>
                <StackLayout Padding="0,30,0,0" x:Name="stckCalculo" VerticalOptions="EndAndExpand">
                    <Button x:Name="btnCalcular" BorderColor="Silver" BackgroundColor="Red" TextColor="White" Text="Prosseguir" />
                </StackLayout>
            </StackLayout>
        </ScrollView>
    </StackLayout>
    <StackLayout IsVisible="{Binding IsBusy}" Padding="12"
          AbsoluteLayout.LayoutFlags="PositionProportional"
          AbsoluteLayout.LayoutBounds="0.5,0.5,-1,-1">
        <Frame Padding="50" OutlineColor="Black" HasShadow="true" AbsoluteLayout.LayoutFlags="PositionProportional" Opacity="0.8" BackgroundColor="Black" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
            <ActivityIndicator  IsRunning="{Binding IsBusy}" Color ="White"/>
            <Label Text="Aguarde..." HorizontalOptions="Center" TextColor="White"/>
        </Frame>
     </StackLayout>
 </AbsoluteLayout>

您可以创建如下自定义单元格

<ListView  x:Name="listView">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                        <StackLayout Orientation="Horizontal">
                            <Image Source="{Binding image}" />
                            <Label Text="{Binding title}"
                            TextColor="#f35e20" />
                        </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

您可以创建如下自定义单元格

<ListView  x:Name="listView">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                        <StackLayout Orientation="Horizontal">
                            <Image Source="{Binding image}" />
                            <Label Text="{Binding title}"
                            TextColor="#f35e20" />
                        </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>


在框架中尝试删除VerticalOptions=“Fill”@AlessandroCaliaro无效。但是,感谢您告诉ListView的StackLayout父对象是
FillAndExpand
,这将占用所有可能的空间。在框架中,尝试删除VerticalOptions=“Fill”@AlessandroCaliaro不起作用。但是,感谢您告诉ListView的StackLayout父对象是
FillAndExpand
,这将占用所有可能的空间。