0

I have an ImageCell as part of a ListView that is supposed to display three pieces of information obtained from the ViewModel for the page via data binding.

XAML:

<ListView x:Name="ScoreListView" ItemsSource="{Binding DBScores}" IsPullToRefreshEnabled="True" RefreshCommand="{Binding RefreshScoresAsyncCommand}" IsRefreshing="{Binding IsBusy, Mode=OneWay}"> <ListView.ItemTemplate> <DataTemplate> <ImageCell Text="{Binding DisplayName}" Detail="{Binding Points}" ImageSource="{Binding SyncImagePath}"/> </DataTemplate> </ListView.ItemTemplate> 

C#

DBScores = new ObservableCollection<ScoresTable>(); 

...

var downloadedList = await App.AzureService.GetScores(); downloadedList = downloadedList.OrderByDescending(x => x.Points).ThenBy(x => x.DisplayName).ToList(); DBScores = new ObservableCollection<ScoresTable>(); foreach (ScoresTable element in downloadedList) { if(element.Synced == 0) { element.SyncImagePath = "notsynced.png"; } else { element.SyncImagePath = "synced.png"; } DBScores.Add(element); } 

...

public class ScoresTable { [JsonProperty("Id")] public string Id { get; set; } public string DisplayName { get; set;} public int Points { get; set; } public DateTime AchievedOn { get; set; } public int Synced { get; set; } public string Latitude { get; set; } public string Longitude { get; set; } [JsonIgnore] public string SyncImagePath { get; set; } } 

The bindings for DisplayName and Points work just fine. I have the relevant images placed in my Android Project's Resources/drawable folder and have added them to the visual studio project. Their names are spelled correctly and have the correct case. When I load the images from the database I check their Synced property and set the image path to one of two images; synced.png or notsynced.png

I'm at a loss because this worked when I went home yesterday, and now it doesn't. I've tried cleaning in VS and manually deleting the bin and obj folders and rebuilding the project.

Edit 1; The Build Actions are set to AndroidResource

Edit 2; This is what I see

7
  • What is the buildaction of the images in your android project? It should be set to "AndroidResource". Commented Nov 16, 2018 at 12:10
  • It is, both images are set to this i.imgur.com/2ZGPvYO.png Commented Nov 16, 2018 at 13:01
  • Have you tried to cleanup the solution? And ensure to delete the "bin" and "obj" folder manually... sometimes the resources are not packed again. Commented Nov 16, 2018 at 13:16
  • I have, I'll give it another go though. Update; no luck. Commented Nov 16, 2018 at 13:17
  • 1
    I've downgraded versions back to 3.3.0.967583 and it suddenly works again. There wasn't any mention of any changes to this stuff in the release notes. I should have thought of this sooner, slow day... Commented Nov 16, 2018 at 13:51

3 Answers 3

3

Downgrading from 3.4.0.1008975 to 3.3.0.967583 fixed it. Must be some issue with the new update or some change I've not seen. There's no mention of any changes to ImageCells in the Release Notes.

Sign up to request clarification or add additional context in comments.

2 Comments

Ditto. The endless stream of bugs in Xamarin frameworks is really making me reconsider my decision. I hope someone on the Xamarin team sees this.
same here, what the heck was that. can't believe that made it to release
1

I had the same exact issue that you did and I also fixed it by reverting from Xamarin.Forms 3.4.0.1008975 to 3.3.0.967583. As you stated, there was no mention of any changes to ImageCells in the Release Notes. I submitted an issue to the Xamarin.Forms GitHub page (and used this StackOverflow post as reference, I hope that's alright. I didn't take the credit for it).

https://github.com/xamarin/Xamarin.Forms/issues/4584

Edit: They did acknowledge this as a bug and they have fixed it, the latest stable version I have found (at the time of writing) is v3.4.0.1009999.

2 Comments

Still dont work, and the only imagesource i get to work is a http image thats not on my phone
@Jonas What version of Xamarin.Forms did you upgrade to? It's recently been reported that v3.5.0.1006868 is also broken. Using v3.4.0.1009999, this works for me. Also, double check your bindings (if you're using bindings). If you're attempting to use the file names, make sure they are included in your Assets/Resources folder of the OS specific project (depends on how you have your project set up, the OS you're trying to work with, etc.)
0

Had the same problem having ImageUrl's as "https://..." using Xamarin.Forms v4.4.0.x. Updated to the latest 4.6.0.x and the problem was gone, images are shown correctly.

Comments