开发者

Display and update a TimeSpan

...Hello,

I explain the problem : In my XAML code, I binded an element with the propertie "Duration" of my class "mTask". "Duration" type is TimeSpan.

When I start a method from the class "mTask" called mStart, I want to update the propert开发者_开发技巧ie "Duration" during the execution of the method, and display it thanks to the binding.

But the problem is I don't know how to keep updated the time span. I was thinking about create a DateTime at the beginning of the method and substract it to the current DateTime.Now during all the execution, is it the solution?

If you need more information, just ask!

Thanks,

Y.


The easiest way would be to write the start time to a field and to let the property "Duration" return DateTime.Now - _startTime.

Update: The class mTask must implement INotifyPropertyChanged and Raise the event of this interface, whenever the value of the property changes. In your case, the value of the property is calculated on the fly, so you would need to raise the event cyclically while your method mStart runs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜