简体   繁体   中英

WPF Bind Value of Library (no PropertyChanged Event)

I am building a Music Player with the NAudio Library. Now it's time to build a clock for the current Time.

Actually my way of doing this, is by binding the Text Property of a Textblock to the CurrentPosition Property (which gives me, who would have given a thought to this, a TimeSpan object consisting of the current position). I want to convert it through an IValueConverter. Because the library doesn't fires a PropertyChanged Event Iam not really sure, what I can do now.

Thank you in advance.

CurrentTime will be continually advancing if you are playing audio, depending on the size of your buffers. It is better to simply poll it a few times a second which will be more than enough. You can either have a timer on your GUI that updates the value, or if you are using MVVM, a timer in your ViewModel that periodically fires a PropertyChanged while you are playing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM