Callback when image is loaded in Xamarin Forms


Pablo Guppi

I have a Listview of Xamarin forms. The content of each cell in the list is text and one or more images. I search for a way to detect when everything in a cell has finished loading. My idea was to use the IsLoading property of Image. The image source is the URL url.

Here is the code for the FlexLayout that loads the list of images:

 <FlexLayout  AlignContent="Center" AlignItems="Center" Direction="Row" JustifyContent="Center" Wrap="Wrap"  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" x:Name="media"   Grid.Row="1"  Margin="0,10,0,10" BindableLayout.ItemsSource="{Binding Media}">

        <BindableLayout.ItemTemplate>
                    <DataTemplate>

                              <Image x:Name="img" Source ="{Binding Url}" HeightRequest="{Binding ListHeigth}" WidthRequest="{Binding ListWidth}"  Aspect="AspectFit" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" />

                    </DataTemplate>
        </BindableLayout.ItemTemplate>
 </FlexLayout>

I haven't found a way to bind the IsLoading property using XAML. As a list, I don't know how to use this attribute in each element:

img.PropertyChanged += (sender, args) =>
        {
            if (args.PropertyName == "IsLoading")
            {
                //do somink
            }
        };

How is the IsLoading property in Xaml bound? Or is there some other callback to detect that all the content of the cell is loaded?

thank you very much.

Road Lu-MSFT

I haven't found a way to bind the IsLoading property using XAML.

IsLoadingThere are just getmethods, no setmethods, so you can't add bindings directly in XAML.

enter image description here

So I recommend you to use FFImageLoading to implement it.

If you want to detect when imageloading is done. You can implement Finishactivities

  <ffimageloading:CachedImage 
            Finish="CachedImage_Finish"
            HorizontalOptions="Center" VerticalOptions="Center"
            WidthRequest="300" HeightRequest="300"
            DownsampleToViewSize="true"
            Source = "http://loremflickr.com/600/600/nature?filename=simple.jpg">
            </ffimageloading:CachedImage>

This is the completion event background code.

  private void CachedImage_Finish(object sender, FFImageLoading.Forms.CachedImageEvents.FinishEventArgs e)
        {
           
        }

If you use MVVM, you can also use FinishCommandand then bind the command in the ViewModel.

You can set if you want to show a loading image while loading LoadingPlaceholder = "loading.png", this is a similar thread.

image load event

Related


Callback when image is loaded in Xamarin Forms

Pablo Guppi I have a Listview of Xamarin forms. The content of each cell in the list is text and one or more images. I search for a way to detect when everything in a cell has finished loading. My idea was to use the IsLoading property of Image. The image sour

Callback when image is loaded in Xamarin Forms

Pablo Guppi I have a Listview of Xamarin forms. The content of each cell in the list is text and one or more images. I search for a way to detect when everything in a cell has finished loading. My idea was to use the IsLoading property of Image. The image sour

Callback when image is loaded in Xamarin Forms

Pablo Guppi I have a Listview of Xamarin forms. The content of each cell in the list is text and one or more images. I search for a way to detect when everything in a cell has finished loading. My idea was to use the IsLoading property of Image. The image sour

Callback when image is loaded in Xamarin Forms

Pablo Guppi I have a Listview of Xamarin forms. The content of each cell in the list is text and one or more images. I search for a way to detect when everything in a cell has finished loading. My idea was to use the IsLoading property of Image. The image sour

Callback when image is loaded in Xamarin Forms

Pablo Guppi I have a Listview of Xamarin forms. The content of each cell in the list is text and one or more images. I search for a way to detect when everything in a cell has finished loading. My idea was to use the IsLoading property of Image. The image sour

Xamarin Forms: onAppearing() does not fire when page is loaded

Shreya In my project I use a dependency service to open the location of the device. After opening the location, I need to modify the UI. I added GPS status check code on onAppearing(). The onAppearing method is the initial trigger and checks the GPS status. If

Image not showing in phone when debugging with Xamarin Forms

Abilami Jyoti <Image Source="https://images2.minutemediacdn.com/image/upload/c_crop,h_842,w_1500,x_0,y_88/f_auto,q_auto,w_1100/v1555006794/shape/mentalfloss/istock-522735736.jpg" /> Here is the code, unable to display image in android device. Jack Wah

Image not showing in phone when debugging with Xamarin Forms

Abilami Jyoti <Image Source="https://images2.minutemediacdn.com/image/upload/c_crop,h_842,w_1500,x_0,y_88/f_auto,q_auto,w_1100/v1555006794/shape/mentalfloss/istock-522735736.jpg" /> Here is the code, unable to display image in android device. Jack Wah

Image not showing in phone when debugging with Xamarin Forms

Abilami Jyoti <Image Source="https://images2.minutemediacdn.com/image/upload/c_crop,h_842,w_1500,x_0,y_88/f_auto,q_auto,w_1100/v1555006794/shape/mentalfloss/istock-522735736.jpg" /> Here is the code, unable to display image in android device. Jack Wah

Image not showing in phone when debugging with Xamarin Forms

Abilami Jyoti <Image Source="https://images2.minutemediacdn.com/image/upload/c_crop,h_842,w_1500,x_0,y_88/f_auto,q_auto,w_1100/v1555006794/shape/mentalfloss/istock-522735736.jpg" /> Here is the code, unable to display image in android device. Jack Wah

Image not showing in phone when debugging with Xamarin Forms

Abilami Jyoti <Image Source="https://images2.minutemediacdn.com/image/upload/c_crop,h_842,w_1500,x_0,y_88/f_auto,q_auto,w_1100/v1555006794/shape/mentalfloss/istock-522735736.jpg" /> Here is the code, unable to display image in android device. Jack Wah

Callback when all ajax is loaded

Newcoma i have this code var chapterNameArr = ['firstchapter','secondchapter','thirdchapter','fourthchapter','fifthchapter','sixthchapter','seventhchapter']; $.each(chapterNameArr, function( index, value ) { var $chapterCont = $("#"+value); $.ajax

Callback when all ajax is loaded

Newcoma i have this code var chapterNameArr = ['firstchapter','secondchapter','thirdchapter','fourthchapter','fifthchapter','sixthchapter','seventhchapter']; $.each(chapterNameArr, function( index, value ) { var $chapterCont = $("#"+value); $.ajax

Callback when all ajax is loaded

Newcoma i have this code var chapterNameArr = ['firstchapter','secondchapter','thirdchapter','fourthchapter','fifthchapter','sixthchapter','seventhchapter']; $.each(chapterNameArr, function( index, value ) { var $chapterCont = $("#"+value); $.ajax

Callback when all ajax is loaded

Newcoma i have this code var chapterNameArr = ['firstchapter','secondchapter','thirdchapter','fourthchapter','fifthchapter','sixthchapter','seventhchapter']; $.each(chapterNameArr, function( index, value ) { var $chapterCont = $("#"+value); $.ajax

Xamarin Forms: Image Caching

Sonali Hi I am trying to build an application using xamarin forms PCL. I am implementing an image library that uses default images. All images are on blobs. I want to download an image and cache that image in the device, after the download is complete I need t

Xamarin forms image recognition

Carlos McMahon I would like to know if there is a recognition system for Xamarin Forms that can use the camera to recognize a point (eg the green solid circle) in order to extract information (eg coordinates) from that point. I know EmguCV can do this, but the

Xamarin Forms: Image Caching

Sonali Hi I am trying to build an application using xamarin forms PCL. I am implementing an image library that uses default images. All images are on blobs. I want to download an image and cache that image in the device, after the download is complete I need t