public class Teams : INotifyPropertyChanged
{
public string CombinedTeams
{
get
{
return Combined;
}
set
{
{
CombinedTeams += value;
NotifiyPropertyChanged("Combined");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifiyPropertyChanged(string p)
{
if (null != p)
{
PropertyChanged(this, new PropertyChangedEventArgs(p));
}
}
private string Combined
{
get
{
return " " + HomeTeam + " " + HomeScore + " - " + AwayScore + " " + AwayTeam;
}
set
{
{
Combined += value;
}
}
}
public string HomeTeam { get; set; }
public string AwayTeam { get; set; }
public string HomeScore { get; set; }
public string AwayScore { get; set; }
}
我有一个问题,想我的琴弦结合在一起,具有包含当我分析我的XML中的所有值一个很长的字符串时,我只得到了第一组值,getter和setter,越来越多领域
基本上我得到
Team1 Score1 : Score2 Team2
,而不是 Team1 Score1 : Score2 Team2 Team3 Score3 : Score4 Team4 Team5 Score5 : Score6 Team6
我绑定我的控制到CombinedTeams
你们能帮我吗?我只是想保存以前的字符串,然后用旧的结合新的字符串,我不能看到它是很难,但这是困惑我,读了它让我更糊涂了......
谢谢,
约翰
我编辑了以上,但我还在挣扎,我不能用我的头周围的getter和setter和inotifiedproperty –
另一个小纸条的人INotifyPropertyChanged的。在设置实际值之前,您不应该调用this.NotifyPropertyChanged(propertyName)。您已经在通知并更新Combined。 – invalidusername