Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,

I am trying to store image from URL into an image viewmodal but getting:

the best overloaded method has some invalid arguments

What I have tried:

Here is what is m trying:

viewModel.Image = ImageSource.FromUri(string.Format("https://www.domain.com/gallery/channels/{0}/{1}.png", Convert.ToString(storydata[0].channel_uuid), Convert.ToString(storydata[0].channel_uuid)));


and my viewModal is like this:

public class ImageViewModel : INotifyPropertyChanged
{
    private ImageSource image;
    public ImageSource Image
    {
        get { return image; }
        set
        {
            image = value;

            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("Image"));
            }
        }
    }

    private string imageStream;
    public string ImageStream
    {
        get { return imageStream; }
        set
        {
            imageStream = value;

            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("ImageStream"));
            }
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;
}



Thanks,
Jassim
Posted
Updated 27-Oct-19 2:39am

1 solution

The ImageSource.FromUri(Uri) Method (Xamarin.Forms)[^] expects a URI class instance as it's single parameter, not a string.
Try this:
C#
viewModel.Image = ImageSource.FromUri(new URI(string.Format(...)));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900