I am having trouble binding an Image to a UriImageSource using Xamarin Forms.
I have implemented the FlowListView which presents a grid-like list of text but the images associated with each product aren't appearing.
Has anyone else had this/know how to work around it?
XAML:
<flv:FlowListView
Grid.Row="1"
x:Name="flvListView"
SeparatorVisibility="None"
HasUnevenRows="true"
FlowColumnMinWidth="110">
<flv:FlowListView.FlowColumnTemplate>
<DataTemplate>
<Grid Padding="3">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image HeightRequest="100" >
<Image.Source>
<UriImageSource Uri="{Binding ProductImage}" />
</Image.Source>
</Image>
<Label
x:Name="Label"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
VerticalOptions="End"
BackgroundColor="Silver"
Opacity="0.5" Text="{Binding ProductName}"/>
</Grid>
</DataTemplate>
</flv:FlowListView.FlowColumnTemplate>
</flv:FlowListView>
View Model:
public class vmProduct
{
public vmProduct() { }
/* removed other properties, constructors etc */
public UriImageSource ProductImage { get; set; }
public string ProductName { get; set; }
}
When the vmProduct is initialised
this.Products.Add(new vmProduct
{
ProductName = "Test",
ProductImage = new UriImageSource
{
Uri = new Uri("https://upload.wikimedia.org/wikipedia/en/5/5f/Original_Doge_meme.jpg")
}
});
(In the above example, "Test" will appear but the image will not)