简体   繁体   中英

Xamarin.Forms Image not showing from Source

I'm using fake Api for testing app.The Api is on this link: http://jsonplaceholder.typicode.com/ . I connect my App, get all photos and add to CollectionView. Everything work perfectly fine but images are not showing.Here is my code:

    <Grid>
    <StackLayout>
        <Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0">
            <Label Text="Welcome to Xamarin.Forms!" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/>
        </Frame>
            <RefreshView IsRefreshing="{Binding IsRefreshing, Mode=OneWay}"
             Command="{Binding LoadRefreshCommand}">
                <CollectionView ItemsSource="{Binding Photos}" SelectedItem="{Binding SelectedPhoto}" >
                    <CollectionView.ItemTemplate>
                        <DataTemplate>

                            <Grid Padding="0,0,5,0" >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="3*"/>

                                </Grid.ColumnDefinitions>
                                <Grid.GestureRecognizers>
                                    <TapGestureRecognizer  Command="{Binding Source={x:Reference CurrentPage}, Path=BindingContext.LoadPhotosCommand}" />
                                </Grid.GestureRecognizers>
                                <Image  Source="{Binding Url}" Grid.Column="0"></Image>
                                <Frame HasShadow="False" VerticalOptions="Center"  Grid.Column="1">
                                    <Label Text="{Binding Title}"></Label>
                                </Frame>
                            </Grid>
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>
            </RefreshView>
        </StackLayout>
        <StackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="Center">
            <Frame IsVisible="{Binding IsBusy}" BorderColor="#07987f" HasShadow="False" BackgroundColor="#eeeeee">
                <StackLayout>
                    <ActivityIndicator IsVisible="{Binding IsBusy}" IsRunning="{Binding IsBusy}" HorizontalOptions="Center" VerticalOptions="Center"></ActivityIndicator>
                    <Label TextColor="#07987f" Text="Loading Data, Please Wait..." HorizontalTextAlignment="Center" VerticalTextAlignment="Center" HorizontalOptions="Center" VerticalOptions="Center" IsVisible="{Binding IsBusy}"/>
                </StackLayout>
            </Frame>
        </StackLayout>
    </Grid>

Here is the image i get from debug app:

在此处输入图像描述

What can be the problem or all images are blank. Also i get this in the console:

[0:] HTTP Request: Could not retrieve https://via.placeholder.com/600/f66b97, status code Gone
[0:] ImageLoaderSourceHandler: Could not retrieve image or image data was invalid: Uri: https://via.placeholder.com/600/f66b97

Anyone had the same problem?

I don't know why source makes a reading problem. This is how i fix it:

  1. Just change the following options and it should work with https too.
  2. Android Options => Advanced
  3. HttpClient implementation = Set to "Managed" option value
  4. SSL/TLS implementation = set to "Native TLS 1.2+" option value

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM