Phi*_*aes 0 c# xaml windows-phone-8
我的XAML:
<Button Click="LikePost" BorderThickness="0" >
<Image Stretch="Uniform" Source="{Binding imagesource}" />
</Button>
Run Code Online (Sandbox Code Playgroud)
第一次设置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));
}
}
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
但是你发送错误的属性名称,改变这个:
NotifyLikeImageChanged("like");
Run Code Online (Sandbox Code Playgroud)
对此:
NotifyLikeImageChanged("imagesource");
Run Code Online (Sandbox Code Playgroud)