我在UWP上遇到了Image
对象的问题。
一旦图片被加载,它的IsLoading属性就拒绝转到False
,因此ActivityIndicator的IsRunning
属性仍然存在...
完全相同的代码片段适用于Android模拟器
<StackLayout>
<ActivityIndicator
IsRunning="{Binding Source={x:Reference Img},Path=IsLoading}"
IsVisible="{Binding Source={x:Reference Img},Path=IsLoading}"
/>
<Image
x:Name="Img"
Source="https://unsplash.it/1980/1080/?random"/>
</StackLayout>
答案 0 :(得分:2)
Xamarin.uwp中的known issue。你可以看到官方已经在上一次commit处理了这个问题。但最新的nuget包尚未发布。您可以关注最新版本的发布日期。
protected virtual async Task TryUpdateSource()
{
// By default we'll just catch and log any exceptions thrown by UpdateSource so we don't bring down
// the application; a custom renderer can override this method and handle exceptions from
// UpdateSource differently if it wants
try
{
await UpdateSource().ConfigureAwait(false);
}
catch (Exception ex)
{
Log.Warning(nameof(ImageRenderer), "Error loading image: {0}", ex);
}
finally
{
((IImageController)Element)?.SetIsLoading(false);
}
}