我已将 Visual Studio 从 2017 (15.9.16) 更新到 2019 (16.3.1)。然后我在 2019 工作室打开旧的(2017)项目,在 Android 模拟器中运行,发现所有以 url 为源的图像都没有显示。我尝试了不同的变体,但没有任何帮助。
然后我创建了用于测试的空白应用程序:
App1 (.Net Standard 2.0) + App1.Android。
主页.xaml:
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Frame HeightRequest="200" BackgroundColor="#E7E7E7">
<Image x:Name="myImage" Aspect="Fill" />
<!--<Image Source="http://lealan.me/Content/images/typist/typist07.jpg" />-->
<!--<Image>
<Image.Source>
<UriImageSource Uri="http://lealan.me/Content/images/typist/typist07.jpg" />
</Image.Source>
</Image>-->
</Frame>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
MainPage.xaml.cs:
public MainPage()
{
InitializeComponent();
var url = "http://lealan.me/Content/images/typist/typist07.jpg";
// variant 1 (not worked)
//this.myImage.Source = ImageSource.FromUri(new Uri(url));
// variant 2 (not worked)
//this.myImage.Source = new UriImageSource() { Uri = …Run Code Online (Sandbox Code Playgroud)