Reputation: 510
My XAML:
<Button Click="LikePost" BorderThickness="0" >
<Image Stretch="Uniform" Source="{Binding imagesource}" />
</Button>
Setting the imagesource for the first time works as expected but whenever I update the source string in my code the XAML does not update, and yes I have included INotifyPropertyChanghed:
public class Item : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private string _imagesource;
public string imagesource
{
get { return _imagesource; }
set
{
if (_imagesource == value) return;
_imagesource = value;
NotifyLikeImageChanged("like");
}
}
private void NotifyLikeImageChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
What I'm I doing wrong?
Upvotes: 0
Views: 75
Reputation: 67928
But you're sending the wrong property name, change this:
NotifyLikeImageChanged("like");
to this:
NotifyLikeImageChanged("imagesource");
Upvotes: 5