Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Binding View Model to a grid.

$
0
0

I am really fade up with the grid. Don't know how to create a grid which will bind Images cause I don't know how many images are coming from API. I did this way -->

        <ListView x:Name="RecipeList" HasUnevenRows="True">

              <ListView.ItemTemplate>
                   <DataTemplate>
                      <ViewCell>

                            <Grid RowSpacing="0" Padding="5">
                             <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                <!--<RowDefinition Height="*"/>-->
                             </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                     <ColumnDefinition Width="*"/>

                            </Grid.ColumnDefinitions>

                                <StackLayout Grid.Row="0"  Grid.Column="0">

                                  <Image x:Name="imge1" Source="{Binding image}" HeightRequest="300" WidthRequest="300"     HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"/>
                                 <Label x:Name="lbl_name"  TextColor="Black" Margin="0,-35,0,0"
                                 HorizontalOptions="CenterAndExpand" VerticalOptions="Start" LineBreakMode="TailTruncation" Text="{Binding title}"  FontFamily="Bold" FontSize="Medium"/>
                            </StackLayout>
                        </Grid>
                    </ViewCell>
                </DataTemplate>

            </ListView.ItemTemplate>

So it will bind the images repectively to row wise. So I want to fix that there should be two columns per row and both columns should have different image. But didn't find the way to implement that.

I am attaching an Image it will help to understand what actually I want to do.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>