我有麻烦的图像结合使用Xamarin表单一个UriImageSource。
我已经实现了FlowListView,该列表呈现了类似网格的文本列表,但是未出现与每种产品相关的图像。
任何人都有这种/知道如何解决它?
<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>
public class vmProduct
{
public vmProduct() { }
/* removed other properties, constructors etc */
public UriImageSource ProductImage { get; set; }
public string ProductName { get; set; }
}
vmProduct初始化时
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")
}
});
(在上面的示例中,将出现“测试”,但图像不会出现)
既然你是绑定UriImageSource
到Uri
你的ViewModel
属性必须是URI来。
更改public UriImageSource ProductImage { get; set; }
为public Uri ProductImage { get; set; }
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句