locked
No images in a grid inside a listview on Windows Phone RRS feed

  • Question

  • User218595 posted

    Hello Everyone,

    I'm using Xamarin Forms version 2.1.0.6526 and running into a strange problem. I have a simple listview with a data template that shows an image and a name. It works perfect on android, but not on windows phone.

    <ListView x:Name="Sheets" RowHeight="128" VerticalOptions="FillAndExpand" IsPullToRefreshEnabled="true" Refreshing="DataRefreshing"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="0.55*" /> <ColumnDefinition Width="0.45*" /> </Grid.ColumnDefinitions>
    <Image Grid.Column="0" Source="DefaultWhiteSheetIcon.png" HeightRequest="128" WidthRequest="128" /> <Label Grid.Column="1" Text="{Binding Name}" /> </Grid> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>

    If I use a stacklayout inside the list, everything works. I checked the datatemplate outside the list, and that works. Just not inside the data template for my listview.

    Any thoughts? Is this a bug, or not supported on Windows Phone?

    Saturday, April 23, 2016 10:13 AM

All replies

  • User89714 posted

    @Daermegil -

    It looks like a bug to me. Using 2.2.0.31, I am finding that UWP and WinRT 8.1 have issues in this scenario. Using a DataTemplate with hard-coded values (so no bindings), I find that some ViewCells show the expected image and some do not. If I update ItemsSource, it usually rectifies the problem, but not always.

    The attached image shows (with garish colors whilst re-factoring) multiple rows in a ListView, where every row should currently look the same, but the images are missing from some cells. It does seem that where an image is missing, all images for that particular cell are missing (there should be a round-cornered box in the lime box at the left, and should be a down arrow at the right).

    I've just checked Bugzilla - this appears to have already been reported (possibly multiple times).

    Friday, May 20, 2016 10:55 AM
  • User89714 posted

    Correction - within one ViewCell, some images can be drawn and others not drawn.

    Friday, May 20, 2016 12:29 PM
  • User67334 posted

    I'm waiting for this bug to be resolved as well....

    Tuesday, August 9, 2016 3:23 AM
  • User76049 posted

    I was seeing the same issue.

    You can get round it in the interim by using FFImageLoading.

    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:ffimageloading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"

    <ListView.ItemTemplate> <DataTemplate> <ViewCell> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="32" /> <ColumnDefinition Width="*" /> <ColumnDefinition> <ColumnDefinition.Width> <OnIdiom x:TypeArguments="GridLength" Tablet="160" Phone="90" /> </ColumnDefinition.Width> </ColumnDefinition> <ColumnDefinition Width="44" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="*" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <ffimageloading:CachedImage Grid.Column="0" Grid.Row="0" Grid.RowSpan="3"> <ffimageloading:CachedImage.Source> <OnPlatform x:TypeArguments="ImageSource" iOS="IconVessInd" Android="IconVessInd" WinPhone="Images/IconVessInd.png" /> </ffimageloading:CachedImage.Source> <ffimageloading:CachedImage.VerticalOptions> <OnPlatform x:TypeArguments="LayoutOptions" iOS="Fill" Android="Fill" WinPhone="Center" /> </ffimageloading:CachedImage.VerticalOptions> </ffimageloading:CachedImage>

    https://www.nuget.org/packages/Xamarin.FFImageLoading.Forms/

    Tuesday, August 9, 2016 8:21 AM