Xamarin表单(Xaml)列表视图不显示图像
我的XAML如下所示:Xamarin表单(Xaml)列表视图不显示图像,xaml,listview,xamarin.forms,Xaml,Listview,Xamarin.forms,我的XAML如下所示: <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="MyApp.Mobile.MyPage">
<ContentPage.Content>
<StackLayout>
<Image Source="http://MyUrl/MyImage.png" /> <!-- WORKS -->
<ListView ItemsSource="{Binding Cells}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Vertical">
<Label Text="{Binding RowName}" />
<Label Text="{Binding ColumnName}" />
<Image Source="http://MyUrl/MyImage.png" /> <!-- DOES NOT WORK-->
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
Xamarin表单(在Android上测试)
第一个图像显示良好。ListView中不显示完全相同的图像。
最终,我将使用像标签这样的绑定(可以工作),但在诊断问题时,我已经硬编码了URL
有人知道为什么图像没有显示在ListView中吗?试试下面的方法
<ListView
HasUnevenRows="True"
ItemsSource="{Binding Cells}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Vertical">
<Label Text="{Binding RowName}" />
<Label Text="{Binding ColumnName}" />
<Image Source="http://xamarin.com/content/images/pages/index/hero.jpg" />
<!-- DOES NOT WORK-->
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
它在我这边工作
快乐编码
Kishore Kumar Vangala.试试下面的方法
<ListView
HasUnevenRows="True"
ItemsSource="{Binding Cells}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Vertical">
<Label Text="{Binding RowName}" />
<Label Text="{Binding ColumnName}" />
<Image Source="http://xamarin.com/content/images/pages/index/hero.jpg" />
<!-- DOES NOT WORK-->
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
它在我这边工作
快乐编码
Kishore Kumar Vangala。我强烈建议在处理listview中的图像时使用FFImageLoading。 性能增益和优化内存消耗巨大强> | 然后在listview中,为了避免单元格大小的问题,最好对
图像指定高度请求
和宽度请求
,然后使用适合您需要的方面(AspectFit
,AspectFill
,ecc…)
刚刚测试过,一切正常。我强烈建议在处理listview中的图像时使用fImageLoading。
性能增益和优化内存消耗巨大强>
|
然后在listview中,为了避免单元格大小的问题,最好对图像指定高度请求
和宽度请求
,然后使用适合您需要的方面(AspectFit
,AspectFill
,ecc…)
刚刚测试过,一切正常。您是否尝试过在ListView上设置hasRows=“True”
?请使用FFImageLoading
!!您是否尝试过在ListView上设置hasRows=“True”
?请为此使用FFImageLoading
!!我很困惑。它适用于你的图像,但不适用于我的!!也许jpg对png?我不知道,花了几个小时在这上面。你的例子成功了,把它放回我的形象,这也成功了!?!?好啊关于下一个问题…请把它作为一个答案,如果它解决了你的问题,它可能对其他人有用@RobL@RobL如果有用的话,请把它标为答案。它适用于你的图像,但不适用于我的!!也许jpg对png?我不知道,花了几个小时在这上面。你的例子成功了,把它放回我的形象,这也成功了!?!?好啊关于下一个问题…请把它作为一个答案,如果它解决了你的问题,它可能对其他人有用@RobL@RobL如果有用,请将其标记为答案。谢谢