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

ListView in StackLayout Mess Binded Images

$
0
0

ListView in StackLayout mess binded images in ItemTemplate/DataTemplate/ViewCell.

Sometimes in the first run, sometimes after rotating the device, some of the images do not show correctly. In this simple project I have 12 list items. Every item has an image and a label. Images shows corresponding numbers. Normally images should be ordered. But from time to time; first, last or any other image (or images) display incorrectly (it displays another image from the resources). In the attached screen captures some number images are incorrect but their labels are correct.

<StackLayout>       
        <ListView x:Name="listView" RowHeight="40">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Image Grid.Column="0" Grid.Row="0" Source="{Binding Image}"></Image>
                            <Label Grid.Column="1" Grid.Row="0" Text="{Binding Name}" VerticalOptions="Center"></Label>
                        </Grid>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackLayout>

When I remove StackLayout and just use ListView no more messing occur. Everyhing works fine. I have spend one day to figure out the problem and finally noticed that the surrounding StackLayout is causing this problematic behavior.

Sometimes it takes too much time to mess up the display (after ten or more rotations).

I have to use other views such as SearchBar on top of ListView in the same page. How could I accomplish this simple task without messing ListView images ?

I am using Xamarin.Forms version 1.2.3.6257


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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