Masha0307
Masha0307

Reputation: 57

How to change the height of item in ListView?

I have a problem with visual displaying of my list view.The height of my items are too small.Firstly I thought that my list is empty.But when I click on the item the action works and information of selected item is transmitted.Then I wrote only 3 labels,and list display only 2 labels and then I understood that height of my item is too small/I tried to change height of my list,ViewCell.View,Labels,but it does not work.Please help me

<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> 

enter image description here

Upvotes: 0

Views: 205

Answers (1)

Junior Jiang
Junior Jiang

Reputation: 12723

There is a Row height property inside ListView:

C#:

RowHeightDemoListView.RowHeight = 100;

Xaml:

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

Upvotes: 1

Related Questions