我的XAML:
<Button Click="LikePost" BorderThickness="0" >
<Image Stretch="Uniform" Source="{Binding imagesource}" />
</Button>第一次设置imagesource的效果与预期一致,但是每当我更新代码中的源字符串时,XAML都不会更新,是的,我已经包含了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));
}
}我做错了什么?
发布于 2013-06-05 21:46:38
但是您发送了错误的属性名称,请更改以下内容:
NotifyLikeImageChanged("like");要这样做:
NotifyLikeImageChanged("imagesource");https://stackoverflow.com/questions/16941629
复制相似问题