I have an app that responds to events and adds the data from the events to a “ListView”, and I have a simple class that have 3 properties.
ListView holds this data:
public string Code { get; set; }
public string Status { get; set; }
public TimeAgo Time { get; set; }
class TimeAgo is:
public class TimeAgo
{
private DateTime _time;
public TimeAgo(DateTime time) { _time = time; }
public override string ToString()
{
return new TimeSpan(DateTime.Now.Ticks - _time.Ticks).Seconds + " seconds ago";
}
}
so, whenever a new event is happening I want the other objects to update, so if I add a new one it says “0 seconds ago” but the old ones should be updated and say “15 seconds ago” so I can track how long ago each event happened when it’s updated.
I’ve searched for methods for this, but all I’ve tried haven’t worked.
Any ideas?
Just make Seconds a property you bind to.
To put at top
For all the items in the ObservableCollection call NotifyPropertyChanged(“Seconds”); after the insert.