簡體   English   中英

Xamarin在其上方的StackLayout重疊布局中形成Listview

[英]Xamarin Forms Listview in StackLayout Overlapping Layout Above It

我有一個ListView,我需要將其堆疊在另一個水平的Stack Layout下。 無論我做什么,似乎ListView都重疊在其上方。 我需要它沒有這種行為,並實際顯示上面的布局。 我只是不知道如何,將不勝感激。

我也嘗試將兩者都放在一個網格中,並設法釋放了頂部的空間,但仍然沒有任何Test標簽出現。

在此處輸入圖片說明

如上所示,ListView只是與其上方的重疊(帶有標簽的堆棧布局),並且與Aaron屏幕上方上方的兩個條目一起顯示。

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             x:Class="engME.YourFullNamesListPage">

    <StackLayout>
        <StackLayout Orientation="Horizontal">
            <Label Text="Test 1" HorizontalTextAlignment="Center"/>
            <Label Text="Test 2" HorizontalTextAlignment="Center"/>
            <Label Text="Test 3" HorizontalTextAlignment="Center"/>
            <Label Text="Test 4" HorizontalTextAlignment="Center"/>
        </StackLayout>
        <StackLayout Orientation="Vertical" VerticalOptions="Fill" HorizontalOptions="FillAndExpand">
            <ListView x:Name="FullNamesList" VerticalOptions="FillAndExpand" RowHeight="50">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="1.1*"/>
                                    <ColumnDefinition Width=".3*"/>
                                </Grid.ColumnDefinitions>
                                <Label FontSize="Large" 
                                       FontAttributes="Bold" 
                                       HorizontalTextAlignment="Start"
                                       Margin="20,0,0,0"
                                       VerticalTextAlignment="Center"
                                       Grid.Row="0"
                                       Grid.Column="0">
                                    <Label.Triggers>
                                        <DataTrigger TargetType="Label" Binding="{Binding Gender}" Value="F">
                                            <Setter Property="Text" Value="{Binding Name}"/>
                                            <Setter Property="TextColor" Value="#cc0066"/>
                                        </DataTrigger>
                                        <DataTrigger TargetType="Label" Binding="{Binding Gender}" Value="M">
                                            <Setter Property="Text" Value="{Binding Name}"/>
                                            <Setter Property="TextColor" Value="#007acc"/>
                                        </DataTrigger>
                                        <DataTrigger TargetType="Label" Binding="{Binding Gender}" Value="A">
                                            <Setter Property="Text" Value="{Binding Name}"/>
                                            <Setter Property="TextColor" Value="#00994d"/>
                                        </DataTrigger>
                                    </Label.Triggers>
                                </Label>
                                <Label Text="{Binding ShortMeaning}"
                                       FontSize="Small"
                                       TextColor="Gray"
                                       VerticalTextAlignment="Center"
                                       Grid.Row="0"
                                       Grid.Column="1">
                                </Label>
                                <Image Source="favorite.png"
                                       Grid.Row="0"
                                       Grid.Column="2"
                                       Scale=".7">
                                </Image>
                            </Grid>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>    
            </ListView>
        </StackLayout>
    </StackLayout>
</ContentPage>

里面有ListView的StackLayout不需要。 刪除它,看看會發生什么。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM