I am trying to get the image from a URL as a BitmapImage but don't know how. The URL was in a list Sharepoint and I already retrieved like this:
public async Task<Microsoft.SharePoint.Client.ListItemCollection> getListContent(string listName)
{
Microsoft.SharePoint.Client.ListItemCollection items;
string userName = Settings.Default.User;
string password = Settings.Default.Pass;
string siteUrl = Settings.Default.URL;
using (ClientContext clientContext = new ClientContext(siteUrl))
{
SecureString securePassword = new SecureString();
foreach (char c in password.ToCharArray())
{
securePassword.AppendChar(c);
}
clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword);
await clientContext.ExecuteQueryAsync();
Microsoft.SharePoint.Client.List TargetList = clientContext.Web.Lists.GetByTitle(listName);
CamlQuery query = CamlQuery.CreateAllItemsQuery();
items = TargetList.GetItems(query);
clientContext.Load(items);
clientContext.ExecuteQuery();
}
return items;
}
One of these fields contains the url to an image in a sharepoint library and I am trying to retrieve it like this:
public Model.Control createModelControl(Microsoft.SharePoint.Client.ListItem item)
{
return new Model.Control
{
BmpImg = new BitmapImage(new Uri((item["Image"] as FieldUrlValue)?.Url))
}
When I inspect the result, this is what I have : enter image description here
I think I need to load it with a client context again, but am not sure of how to do it. With Sharepoint on premise, there was a method called "DownloadData" but it does not seem to exist with SPO...
Any ideas?