I've got a complex back-end process that runs for a long period of time. All the vital stats are exposed as properties with INotifyPropertyChanged
events raised when they're set.
I wanted to add an "Elapsed time" which is proving far more challenging than anticipated.
I exposed a ProcessStartedAt
DateTime and threw together a converter to subtract the bound time from DateTime.Now
. This works perfectly (once). After that, since the property isn't changing, the binding is never updated and the converter isn't called again.
I don't want the back-end to have a timer dedicated to updating an "Elapsed time" property. It violates the separation of concerns principle. I'd be happier with a timer in the UI but am unsure how to force a binding to refresh without updating the property value.
Even better, is there a way I can tell the binding to refresh at regular intervals?
<TextBlock Text="{Binding Path=ProcessStartedAt,
Converter={StaticResource ElapsedTime}}"/>