views:

30

answers:

1

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' 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?

+1  A: 

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: http://stackoverflow.com/questions/2192612/how-do-i-handle-canvas-top-change-event-in-wpf/2207668#2207668

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... :)

Andreas