【问题标题】:How to change the height of item in ListView?如何更改 ListView 中项目的高度?
【发布时间】:2020-11-19 10:27:16
【问题描述】:

我的列表视图的视觉显示有问题。我的项目的高度太小。首先我认为我的列表是空的。但是当我单击项目时,操作有效并且所选项目的信息被传输.然后我只写了3个标签,列表只显示2个标签,然后我明白我的项目高度太小/我试图改变我的列表高度,ViewCell.View,Labels,但它不起作用。请帮忙我

<ContentView.Content>
        <controls:CustomFrame CornerRadius="25,25,0,0" Margin="0" Padding="10" HorizontalOptions="FillAndExpand"  VerticalOptions="FillAndExpand">
           
            <StackLayout Padding="0">
           <!-- <StackLayout.GestureRecognizers>
                <SwipeGestureRecognizer Direction="Up"  Command="{Binding RefreshCommand}"  ></SwipeGestureRecognizer>
            </StackLayout.GestureRecognizers>-->
            <ListView ItemsSource="{Binding MyPins}"  x:Name="ListPlaces"  IsPullToRefreshEnabled="True"   RefreshCommand="{Binding RefreshCommand}"
       IsRefreshing="{Binding IsRefreshing}"
                   SelectionMode="None">

                <ListView.ItemTemplate >
                    <DataTemplate>
                        <ViewCell>
                            <ViewCell.View>
                                <Frame CornerRadius="10" BackgroundColor="LightBlue">
                                <StackLayout  Orientation="Vertical" Padding="0">
                                    <StackLayout.GestureRecognizers>
                                        <TapGestureRecognizer  CommandParameter="{Binding .}"    Command="{Binding BindingContext.CallPlace, Source={x:Reference ListPlaces}}"  ></TapGestureRecognizer>
                                    </StackLayout.GestureRecognizers>
                                    <Label x:Name="NameOfPlace" Text="{Binding MyPins.Name}" TextColor="#2D78FD" FontSize="14" FontFamily="Robobo"/>
                                    <Label x:Name="AdressOfPlace" Text="{Binding MyPins.Address}"  TextColor="#616161" FontSize="12" FontFamily="Robobo"/>
                                    <StackLayout Orientation="Horizontal">
                                        <Label x:Name="TimeWork" VerticalOptions="Center" Text="Open until  -  "  TextColor="#616161" FontSize="12" FontFamily="Robobo"/>
                                        <Label x:Name="TimeWork1" VerticalOptions="Center" Text="{Binding Opened}"  TextColor="#616161" FontSize="12" FontFamily="Robobo"/>
                                        <Image Source="openIcon" VerticalOptions="Center" />
                                        <Button HeightRequest="24" VerticalOptions="Center" Padding="0,-3,0,0" WidthRequest="92" HorizontalOptions="EndAndExpand" FontSize="14" CornerRadius="45" BackgroundColor="#2D78FD" TextColor="White" Text="Call up"/>
                                    </StackLayout>

                                </StackLayout>
                                </Frame>
                            </ViewCell.View>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </StackLayout>
       
    </controls:CustomFrame>

</ContentView.Content> 

【问题讨论】:

标签: c# xaml xamarin xamarin.forms xamarin.android


【解决方案1】:

ListView 内部有一个Row height 属性:

C#:

RowHeightDemoListView.RowHeight = 100;

Xaml:

<ListView x:Name="RowHeightDemoListView" RowHeight="100" />

【讨论】:

    猜你喜欢
    • 2020-11-25
    • 1970-01-01
    • 2014-08-07
    • 1970-01-01
    • 2022-06-23
    • 2016-11-01
    • 2011-09-27
    • 2021-01-20
    • 1970-01-01
    相关资源
    最近更新 更多