【问题标题】:cannot display image in xamarin forms无法以 xamarin 形式显示图像
【发布时间】:2016-11-01 01:12:25
【问题描述】:

我正在尝试构建一个简单的应用程序以在堆栈布局中显示图像, 这是代码

  <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="HelloWorld.Page1">
  <StackLayout BackgroundColor="White">
    <Image Source="http://placehold.it/300x300"/>
  </StackLayout>
</ContentPage>

但由于某种原因,它根本不显示图像。 有没有人看到这里有问题。

谢谢!!

【问题讨论】:

  • 当我将该网址粘贴到浏览器中时,我被重定向到placeholdit.imgix.net/…。尝试使用它。图像处理程序不太可能遵循重定向。
  • 我尝试添加此链接lorempixel.com/1920/1080/nature/3,但仍然无法正常工作
  • 确保您已更新项目中的 Xamarin.Forms nuget 包。我只是拿了那个确切的代码,它起作用了。我在 Windows UWP 和 iOS 上进行了测试。

标签: c# xaml xamarin xamarin.android xamarin.forms


【解决方案1】:

您可能没有格式良好的页面?

<?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:local="clr-namespace:QuickTestXAMLImage"
             x:Class="QuickTestXAMLImage.MainPage">

  <StackLayout BackgroundColor="White">
    <Image Source="http://placehold.it/300x300"/>
  </StackLayout>

</ContentPage>

请注意,我有一个 xmlns:local,其中包含应用程序的本地命名空间。您可能没有完整的页面,导致它甚至无法正确加载。

这对我来说很好。

【讨论】:

  • 好吧,我只是在尝试不同的东西,而我正在尝试包含本地图像。出于某种原因,除了图像之外,xamarin 中的其他一切都适用于我。
猜你喜欢
  • 2018-06-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多