locked
imagenes no aparecen RRS feed

  • Question

  • User390420 posted

    Hola a todos tengo una aplicacion web con asp net core y xamarin form en donde envio las imagenes a mi movil pero no aparecen las envio por uri y estoy usando una direccion ssl, pero no me muestran las imagenes y si estan bien dioreccionadas, favor au ayuda comunidad

    Friday, November 15, 2019 2:41 AM

All replies

  • User89714 posted

    @compusystemecu

    You will need to provide more information for anybody to be able to help. Post the relevant pieces of code and XAML from your Xamarin.Forms app, showing how your app obtains and attempts to display the image. Also, have you debugged to identify what is failing? If so, provide details of which piece is failing, including details of any exceptions.

    Also, please read the forum rules and guidelines at https://forums.xamarin.com/discussion/87290/xamarin-forum-rules-and-guidelines#latest , which say "you may not hold a conversation in the forums in languages other than English". (If you are not confident about using English, please post in English as best you can, but then have the same text in your native language below the English so that Spanish speakers can refer to it if required).

    Friday, November 15, 2019 10:49 AM
  • User390420 posted

    I enclose my code, it does not present the image in my android app, but if it is well sent my uri, and if it is saving the image, it simply does not present me, I saw something like there are problems when the address is hhtps, please help me

    Adjunto mi codigo, no me presenta la imagen en mi app android, pero si esta bien enviado mi uri, y si esta guardando la imagen, simplemente no me la presenta, vi algo como que hay probleas cuando la direccion es hhtps, favor ayudenmen

       private async void LoadProducts()
        {
            this.IsRefreshing = true;
    
            var url = Application.Current.Resources["UrlAPI"].ToString();
            var response = await this.apiService.GetListAsync<Product>(
                url,
                "/api",
                "/Products",
                "bearer",
                MainViewModel.GetInstance().Token.Token);
    
            this.IsRefreshing = false;
    
            if (!response.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    response.Message,
                    "Accept");
                return;
            }
    
            this.myProducts = (List<Product>)response.Result;
            this.RefresProductsList();
        }
    
    
    
    
       private void RefresProductsList()
        {
            this.Products = new ObservableCollection<ProductItemViewModel>(
                myProducts.Select(p => new ProductItemViewModel
                {
                    Id = p.Id,
                    ImageUrl = p.ImageUrl,
                    ImageFullPath = p.ImageFullPath,
                    IsAvailabe = p.IsAvailabe,
                    LastPurchase = p.LastPurchase,
                    LastSale = p.LastSale,
                    Nombre = p.Nombre,
                    Precio = p.Precio,
                    Stock = p.Stock,
                    User = p.User
                })
            .OrderBy(p => p.Nombre)
            .ToList());
        }
    

    * view my xaml BindingContext="{Binding Products}" Padding="8">

                                <Image
                                    Grid.Column="0"
                                    **Source="{Binding ImageFullPath}"**
                                    WidthRequest="100">
                                </Image>
    
                                <StackLayout
                                    Grid.Column="1"
                                    VerticalOptions="Center">
                                    <Label
                                        FontAttributes="Bold"
                                        FontSize="Medium"
                                        Text="{Binding Nombre}"
                                        TextColor="Black">
                                    </Label>
                                    <Label
                                        Text="{Binding Precio, StringFormat='Precio: {0:C2}'}"
                                        TextColor="Navy">
                                    </Label>
                                    <Label
                                        Text="{Binding Stock, StringFormat='Stock: {0:N2}'}"
                                        TextColor="Black">
                                    </Label>
                                </StackLayout>
                                <Image
                                    Grid.Column="2"
                                    Source="ic_chevron_right">
                                </Image>
                            </Grid>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </StackLayout>
    </ContentPage.Content>
    

    Friday, November 15, 2019 4:40 PM
  • User89714 posted

    @compusystemecu

    Can you re-post your XAML. To get it to format correctly. put three back ticks (with nothing in between) on the line before the XAML and three back ticks on the line after the XAML. In case you cannot find the back tick on your keyboard, there is one at the end of this line that you can copy and paste - `

    Also, when re-posting your XAML, please remove any edits that you did to try to highlight particular lines. We need to see the XAML that you are using, rather than an edited version.

    Also, three bits from what I can see in your previous post: (1) I believe you are wanting to load images from URLs. For this you should use UriImageSource. See https://stackoverflow.com/questions/40579372/bind-image-to-url-xamarin-forms-xaml (2) LoadProducts() returns async void rather than async Task. Depending on what the caller is doing, that may introduce a race-condition. (3) You are replacing this.Products with a new collection, rather than updating the existing collection.

    Friday, November 15, 2019 4:51 PM
  • User390420 posted

    No se como publicar el XAML de nuevo, y eso de poner marcas no entiendo. Tengo un api service para utilizar los recursos de mi direccion web publicada en azure pero esat direccion es hhttps De alli al cragar mi app en android me pide usuario y clave doy aceptar y mando a cargar mi lista de productos, todo me presenta muy bien excepto las imagenes de los productos, pero si esta bien direccionado es mas le copio la direccion web y me paarece la imagen pero en la app no me la presenta, estoy como loco no se porque no presenta. Esta es una imagen que esta publicada https ://shoprs.azurewebsites.net/images/Products/39e1e0c9-ee9f-45d2-8699-917275d2ec83.jpg

    I don't know how to publish the XAML again, and I don't understand that about putting marks. I have an api service to use the resources of my web address published in azure but this address is hhttps From there to cragar my app on Android asks me user and password I accept and send my product list to load, everything presents me very well except the images of the products, but if it is well addressed it is more I copy the web address and I It looks like the image but in the app it does not present it to me, I am crazy I do not know why it does not present. This is an image that is published http s://shoprs.azurewebsites.net/images/Products/39e1e0c9-ee9f-45d2-8699-917275d2ec83.jpg

    Friday, November 15, 2019 5:00 PM
  • User390420 posted

    He did not allow me to link but all together https: // no me permitio poner link pero todo unido https://

    Friday, November 15, 2019 5:01 PM
  • User89714 posted

    @JohnHardman said: @compusystemecu

    Also, three bits from what I can see in your previous post: (1) I believe you are wanting to load images from URLs. For this you should use UriImageSource. See https://stackoverflow.com/questions/40579372/bind-image-to-url-xamarin-forms-xaml (2) LoadProducts() returns async void rather than async Task. Depending on what the caller is doing, that may introduce a race-condition. (3) You are replacing this.Products with a new collection, rather than updating the existing collection.

    Try (1) and let us know the result.

    Friday, November 15, 2019 5:06 PM
  • User390420 posted

    [0:] ImageLoaderSourceHandler: Could not retrieve image or image data was invalid: Uri: http://shoprs.azurewebsites.net/images/Products/39e1e0c9-ee9f-45d2-8699-917275d2ec83.jpg

    Friday, November 15, 2019 5:24 PM
  • User390420 posted
    1. Finally add this property to Product entity:

    public string ImageFullPath { get { if (string.IsNullOrEmpty(this.ImageUrl)) { return null; }

        return $"https://shopzulu.azurewebsites.net{this.ImageUrl.Substring(1)}";
    }
    

    }

    Friday, November 15, 2019 5:32 PM
  • User89714 posted

    @JohnHardman said:

    (1) I believe you are wanting to load images from URLs. For this you should use UriImageSource. See https://stackoverflow.com/questions/40579372/bind-image-to-url-xamarin-forms-xaml

    In the thread mentioned in (1), it's specifically the bit at https://stackoverflow.com/a/40579671/4825120 that you should look at

    Friday, November 15, 2019 6:16 PM