<?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="Training.InstagramPage">
<ContentPage.Padding>
<OnPlatform x:TypeArguments="Thickness" iOS="0, 20, 0, 0" />
</ContentPage.Padding>
<StackLayout>
<StackLayout Padding="20,0,0,0">
<Label x:Name="lblTitle">nyc_photographer</Label>
</StackLayout>
<Image Source="http://lorempixel.com/1920/1080/nature/3/"/>
<StackLayout Orientation="Horizontal" Padding="20,0,0,0">
<Button x:Name="btnLike" TextColor="#127ac7" BackgroundColor="Transparent" Text="Like"></Button>
<Button x:Name="btnComment" TextColor="#127ac7" BackgroundColor="Transparent" Text ="Comment"></Button>
<Button x:Name="btnShare" TextColor="#127ac7" BackgroundColor="Transparent" Text="Share"></Button>
</StackLayout>
<BoxView Color="#f0f0f0" HeightRequest="1"></BoxView>
<StackLayout Padding="20,0,20,0">
<Label x:Name="lblTotalLikes" FontAttributes="Bold">700 Likes</Label>
<Label x:Name="lblDescription" TextColor="Gray">This is a shot yesterday in Skanor, Sweden, When driving home, from a couple of days of work in Denmark</Label>
</StackLayout>
</StackLayout>
</ContentPage>
嗨,在上面的代码中,使用 Visual Studio android 模拟器根本不显示图像。它在 Windows 应用程序上运行良好。
该页面运行良好,但突然停止。我试图用一个图像标签创建一个新项目,但图像仍然没有显示在 android 模拟器上。
我修复/卸载/安装了Visual Studio Community 2015,但仍然没有显示。
我还删除了hyper v图像,卸载而不是重新安装hyper v,但仍然没有运气
我还尝试使用后面的代码加载图像,如下所示:
img.Source = new UriImageSource
{
Uri = new Uri("http://lorempixel.com/1920/1080/city/1/"),
CachingEnabled = false,
CacheValidity = TimeSpan.FromHours(1)
};
还是不显示!
注意:我可以从模拟器浏览器导航到图像路径
我正在将 Windows 10 与 Visual Studio Community 2015 一起使用。
有人面临同样的问题吗?解决办法是什么 ?
更新:我检查了调试输出,我得到了以下信息:
Thread started: <Thread Pool> #9
01-29 05:26:05.129 D/Mono ( 1510): [0xba853170] worker starting
01-29 05:26:05.629 W/ ( 1510): _wapi_connect: error looking up socket handle 0x1f
[0:] Image Loading: Error getting stream for http://lorempixel.com/1920/1080/nature/3/: System.Threading.Tasks.TaskCanceledException: A task was canceled.
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0002d] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:179
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357
at System.Net.Http.HttpClientHandler+<SendAsync>c__async0.MoveNext () [0x004a7] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:389
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00027] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:176
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535
at System.Net.Http.HttpClient+<SendAsyncWorker>c__async0.MoveNext () [0x000a9] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00027] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:176
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357
at Xamarin.Forms.Forms+AndroidPlatformServices+<GetStreamAsync>d__14.MoveNext () [0x0003e] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Forms.cs:363
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00027] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:176
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535
at Xamarin.Forms.UriImageSource+<GetStreamAsyncUnchecked>d__22.MoveNext () [0x00224] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\UriImageSource.cs:166
Thread finished: <Thread Pool> #8
01-29 05:26:26.768 D/Mono ( 1510): [0xb9f4da10] worker finishing
The thread 'Unknown' (0x8) has exited with code 0 (0x0).