问题
to add clarity to the below. I was considering using timers or storyboard.CurrentTimeInvalidated but the storyboard is for a metronome and the timings are in milliseconds: therefore:
CurrentTimeInvalidated does not raise events every millisecond from what I have seen in debug, it seems to raise every 200ms.
Timers have to be initialised in code and obviously this happens sequentially with the storyboard.begin. as a result the timers go out of alignment over a period of about 30 seconds.
I think the title pretty much sums up what I want to do, but, in detail.
I have 8 user controls that are created dynamically at runtime. I have a window that is running a storyboard and animation throughout the lifetime of the window (repeat behaviour = forever and autoreverse = true).
what I need to do is at set intervals in the storyboard call a method in the usercontrols (in sequence).
is it possible to bind to the storyboard and create a trigger that calls a usercontrol method?
thanks
Dan.
回答1:
Firstly, the WPF frame rate is 60 FPS so millisecond UI updates are not possible. If you want to tap into the rendering of each frame, use CompositionTarget.Rendering event
http://msdn.microsoft.com/en-us/library/system.windows.media.compositiontarget.rendering.aspx
来源:https://stackoverflow.com/questions/11180903/use-a-storyboard-to-call-a-method-in-a-usercontrol-created-dynamically