【问题标题】:Xamarin.Forms Image in ListView DataTemplate not appearing in WinPhone 8.1ListView DataTemplate 中的 Xamarin.Forms 图像未出现在 WinPhone 8.1 中
【发布时间】:2016-04-22 11:36:51
【问题描述】:

图像 XAML 组件在 Windows Phone 8.1 的 Xamarin.Forms 中放置在列表视图数据模板中时不起作用。图像在 Android 和 iOS 中显示良好。

  <ListView x:Name="recipeList" ItemsSource="{Binding Tweets}" HasUnevenRows="true">
  <ListView.ItemTemplate>
    <DataTemplate>
      <ViewCell> 
       <ViewCell.View>                  
        <StackLayout>
          <Image Source="{Binding ImageURI"} />
        </StackLayout>
       </ViewCell.View>
      </ViewCell>
     </DataTemplate>
   </ListView.ItemTemplate>

其中 ImageURI = "http://some-image-off-the-web.jpg"

更新 在 UWP 中,文本甚至不会出现!忘记图像,实际的文本是不可见的。我可以看到每个列表项都是使用 Visual Studio Live Property Explorer 填充的,每个列表项中肯定有要显示的文本,它只是不可见的。我删除了标签所在的网格,它工作正常。图像仍未显示。 ViewCells 在 Windows 中不能很好地工作吗?

【问题讨论】:

  • ImageUri 看起来怎么样?您是从资源加载图像还是从网络加载图像?
  • 它们来自网络(见编辑),让我们说当我将图像从 ListView DataTemplate 中取出时,它呈现得很好。或者,如果我再次使用 ImageCell 而不是 ViewCell 图像渲染得很好。 :(

标签: xaml listview xamarin.forms


【解决方案1】:

查看 StackLayout 中的图像源。

    <StackLayout>
      <Image Source="{Binding ImageURI"} />
    </StackLayout>

引号未对齐。

【讨论】:

    猜你喜欢
    • 2020-03-04
    • 2017-07-17
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 2017-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多