views:

183

answers:

1

i want a silverlight listbox whose items are automatic scrollable (like a vertical marquee)

+3  A: 

You might try using an ItemsControl setting the ItemsControl.ItemPanel to a StackPanel with a TranslateTransform applied on it. Then you can have a running Storyboard that adjusts the position of the Y coordinate of the Translate Transform.

EDIT: Example

<Border BorderBrush="Black" BorderThickness="2" 
        Height="100" Width="100" 
        HorizontalAlignment="Left" VerticalAlignment="Top" >
    <Border.Clip>
        <RectangleGeometry Rect="0,0,100,100" />    
    </Border.Clip>
    <ItemsControl ItemsSource="{StaticResource Collection}">
        <ItemsControl.RenderTransform>
            <TranslateTransform x:Name="Transform" />
        </ItemsControl.RenderTransform>
        <i:Interaction.Triggers>
            <i:EventTrigger>
                <ei:ControlStoryboardAction 
                    Storyboard="{StaticResource TransformMove}"/>
        </i:EventTrigger>
        </i:Interaction.Triggers>
    </ItemsControl>
</Border>

Then include this Storyboard in your control resources:

<Storyboard x:Key="TransformMove" Storyboard.TargetName="Transform" Storyboard.TargetProperty="Y">
    <DoubleAnimation From="-100" To="100" Duration="0:0:10" 
                     RepeatBehavior="Forever"/>
</Storyboard>
Stephan
i am not able to get ControlStoryBoardAction in blend 4, is this complete code or i have to write some extra bits to get this working ...and thanks
taher chhabrawala
The ControlStoryboardAction is in Blend 4. The namespace I defined is xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" and I believe they are in Microsoft.Expression.Interactions.dll. You will probably need to fiddle with the Width/Height of the Border and the Rect of the Clipping region to get it looking right, but it should function as is.
Stephan