Reputation:
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
Upvotes: 0
Views: 1876
Reputation: 180
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.
Upvotes: 0
Reputation: 21
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.
Upvotes: 1
Reputation:
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.
Upvotes: 3