0

我的 XAML:

<Button Click="LikePost" BorderThickness="0" >
    <Image Stretch="Uniform" Source="{Binding imagesource}" />
</Button>

第一次设置图像源按预期工作,但每当我更新代码中的源字符串时,XAML 不会更新,是的,我已经包含了 INotifyPropertyChanged:

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));
    }
}

我做错了什么?

4

1 回答 1

5

但是您发送了错误的属性名称,请更改:

NotifyLikeImageChanged("like");

对此:

NotifyLikeImageChanged("imagesource");
于 2013-06-05T13:46:37.997 回答