Double Animation item detection
I'm currently writing a marquee control for WPF. The control consists of an ItemsControl, with TextBlock as the DataTemplate element of choice. The ItemsControl is the target of a Double Animation, which manipulates the Canvas.Left property.
What I would like to do is create a "circular mode", which will allow the marquee to dynamically add an item to its'开发者_如何学JAVA tail whenever the last item has scrolled into view. That way, the marquee will never appear empty.
How can I detect when a TextBlock has "scrolled" into view (effectively become visible) as a result of the animation?
It might work that you check whether the ItemControl
's ActualWidth
property is greater than the current Canvas.Left
value of your TextBlock
.
To get the change event, have a look at this SO: How do I handle Canvas.Top change event in WPF?
Maybe it is useful to keep a references to the last control that was added to the tail of your marquee, so that you can remove the event handler once the control is scrolled into view and attach the event handler to the TextBlock
that is then added to the tail.
It would be nice to be able to draw something for a better understanding. If anything's unclear (technically or conceptually) ask, ask, ask... :)
精彩评论