Forum Xamarin.Forms

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

listwview item not set to fit to grid

this is my code
display 5 plus item,
then fit to grid
but get 2 item
item was show
but allocate the space plz give me solution


<Grid.RowDefinitions>


</Grid.RowDefinitions>

                    <Label x:Name="lblError" Text=""
                VerticalOptions="CenterAndExpand" 
                HorizontalOptions="CenterAndExpand">
                    </Label>
                    <!--First Round Player List-->

                <Label Text="First Round" TextColor="Red" FontSize="20" BackgroundColor="Gray" HeightRequest="40" Grid.Row="0" />

                <ListView x:Name="tournamentMatchList" Grid.Row="1"
                         ItemSelected="TournamentMatchList_ItemSelected"
                          HasUnevenRows="True"
                          RowHeight="180" VerticalOptions="FillAndExpand">
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <ViewCell>
                                <StackLayout  Spacing="2" Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
                                    <Frame HasShadow="True" CornerRadius="10" Padding="5" Margin="3" BorderColor="Black">
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="*"/>
                                                <ColumnDefinition Width="180"/>
                                                <ColumnDefinition Width="*"/>
                                            </Grid.ColumnDefinitions>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="*"/>
                                                <RowDefinition Height="30"/>
                                            </Grid.RowDefinitions>

                                            <Grid  Grid.Column="0" Grid.Row="0" >
                                                <StackLayout Orientation="Vertical" >
                                                    <Image x:Name="pp" Source="{Binding TeamFirstImageSource}" 
                                                           Aspect="AspectFit" HeightRequest="100"
                                                            VerticalOptions="Start" HorizontalOptions="Start"                                  
                                                           />
                                                    <Label x:Name="matchFirst" TextColor="Black"     
                                                    VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"
                                                           Text="{Binding TeamFirst}" FontSize="15"
                                                     LineBreakMode="NoWrap"/>
                                                </StackLayout>
                                            </Grid>

                                            <Grid  Grid.ColumnSpan="3" Grid.Row="1" BackgroundColor="Yellow">
                                                <Label x:Name="trnTemsLotsDate" TextColor="Black"     
                                                  VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" 
                                                       Text="{Binding DateTime, StringFormat='{}{0:dddd,dd.MM.yyyy hh:mm tt}'}" 
                                                       FontSize="18"
                                                       FontAttributes="Bold"
                                                   LineBreakMode="NoWrap" />
                                            </Grid>


                                            <Grid Grid.Column="2" Grid.Row="0" >
                                                <StackLayout Orientation="Vertical">
                                                    <Image Source="{Binding TeamSecondImageSource}" Aspect="AspectFit"
                                                            HeightRequest="100"                                                             
                                                            VerticalOptions="Start" HorizontalOptions="Start"/>

                                                    <Label x:Name="matchFirstTeam" TextColor="Black"     
                                                         VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" 
                                                           Text="{Binding TeamSecond}" FontSize="15"
                                                          LineBreakMode="NoWrap" />
                                                </StackLayout>
                                            </Grid>
                                        </Grid>
                                    </Frame>
                                </StackLayout>
                            </ViewCell>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                        </ListView >


                </Grid>

Best Answer

Answers

  • sandy3080sandy3080 Member ✭✭

  • sandy3080sandy3080 Member ✭✭

    @jarvan sir please check it its my output

  • YelinzhYelinzh Member, Xamarin Team Xamurai
    edited November 2019

    @sandy3080
    Do you mean the area marked in picture? The code works on my side. Here is the demo file you can refer to or you can post a basic demo to reproduce the issue for a solution.

  • sandy3080sandy3080 Member ✭✭
    edited November 2019
    no
    its okkk
    I have given m margin and center

    but
    Space allocated in down side
  • sandy3080sandy3080 Member ✭✭
    i have sent pic ckeck it ,
    when list bound 5 plus items i is show it but
    when list bound item 1,2,3
    that time down side space allocate

    actully
    this is first round
    total round are five
  • YelinzhYelinzh Member, Xamarin Team Xamurai

    Because all items are taller than the ListView. Some items will be hidden and you can scroll to display them. If you want to display all items, reduce the value of the image's HeightRequest to 30. But in this case, the listview cannot be scrolled.

    <Grid  Grid.Column="0" Grid.Row="0" >
        <StackLayout Orientation="Vertical" >
            <Image x:Name="pp" Source="grid_" 
                HeightRequest="30"
                VerticalOptions="Start" HorizontalOptions="Start" />
            ...
        </StackLayout>
    </Grid>
    
    <Grid  Grid.ColumnSpan="3" Grid.Row="1" BackgroundColor="Yellow">
        ...
    </Grid>
    
    <Grid Grid.Column="2" Grid.Row="0" >
        <StackLayout Orientation="Vertical">
            <Image Source="one"
                HeightRequest="30"                                                             
                VerticalOptions="Start" HorizontalOptions="Start"/>
            ...
        </StackLayout>
    </Grid>
    

  • sandy3080sandy3080 Member ✭✭

    exact what a problem
    i have sent all pic
    check it
    5 collpas grid
    any collaps grid open first,
    this collaps allocate space
    then all over okk problem only starting grid

  • sandy3080sandy3080 Member ✭✭






  • YelinzhYelinzh Member, Xamarin Team Xamurai

    Do you mean to one ListView content per round? If so, try to use CarouselView. A single item will be displayed on screen when scrolling.

Sign In or Register to comment.