Hello I am attempting to make an event countdown but running into some issues.
This function gets called:
private void RunEventCountdowns()
{
Device.StartTimer(new TimeSpan(0, 0, 1), () =>
{
if (isCounting)
{
Device.BeginInvokeOnMainThread(() =>
{
OnPropertyChanged("propChanged");
});
return true;
}
else
{
return false;
}
});
}
isCounting is set true in OnAppearing()
Then:
public event PropertyChangedEventHandler propChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = propChanged;
foreach (var evt in EventList)
{
tSpan = evt.Date - DateTime.Now;
evt.Time = tSpan;
System.Diagnostics.Debug.WriteLine(evt.Name + " is this far away: " + evt.Time.ToString());
}
}
Tspan is just a Timespan
The binding on front end halfway works - the name property appears fine but the countdown string never updates. If I set itemsource to null then change it back to my observablecollection source it updates..but then my memory constantly increases, and doesn't seem like the proper way to do this.
My debug pretty much shows the information I want to see on the front end. What am I doing wrong here?
With the help of the first comment I was able to figure this out by adding a setter with PropertyChanged on my model.
As well as the following event: