I have a small problem with my C# code and binding a property.
Here I have the following xaml:
<Image Source="{Binding downloaded, Source={StaticResource itemsViewSource}}" Width="20" Height="20" Margin="5" HorizontalAlignment="Right" VerticalAlignment="Top"/>
And there is the code I'm trying to make working:
class Ressource : INotifyPropertyChanged
{
public String downloaded { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
Debug.WriteLine("Property changed.");
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
My problem is that the NotifyPropertyChanged function is called (the debug appears), the string content is changed but I don't see my image appear.
Does anyone have a solution to this.
Thanks!
EDIT: After multiple useful answers but no change appearing even if the propertyChanged function is called,I'm starting to wonder if maybe changing the path of the image source is really possible.
Can the image be updated when the path is changed?
Here is the code after the changes suggested:
public class Ressource : INotifyPropertyChanged
{
public String downloaded
{
get
{
return _downloaded;
}
set
{
_downloaded = value;
if (PropertyChanged != null)
PropertyChanged(this,new PropertyChangedEventArgs("downloaded"));
}
}