图像的IsLoading属性被卡住了

时间:2017-04-27 17:06:50

标签: xaml xamarin uwp xamarin.forms

我在UWP上遇到了Image对象的问题。 一旦图片被加载,它的IsLoading属性就拒绝转到False,因此ActivityIndi​​cator的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>

enter image description here

1 个答案:

答案 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);
    }
}