index > Windows Presentation Foundation ("Avalon") > animate listbox items to scroll

animate listbox items to scroll

how to animate listbox items to scroll and fade out
Chidu
Can you give some more details
lee d
i have a small project i'm working on thats Similar to the RSS Feeder in the Vista SideBar...So the Question is where can i get a good example for Scrolling the RSS Feeds Upon the ListBox being Populated??

As of right now my project just uses a Veritcal ScrollBar,i want it to Auto Scroll on its own as the Feeds are Feed into the project,and have a Fading appearance,as the Feeds reach the top of the ListBox

Right now i use the following which scrolls the entire list box. I need to scroll only the items inside the listbox and to fade it out on reaching the top of the listbox.

<DataTemplate x:Key="dt1">
<TextBlock Height="30">
<TextBlock Text="{Binding}"/>
</Hyperlink>
</TextBlock>
</DataTemplate>
</Window.Resources>

<Canvas Width="150" Height="200">
<ListBox Name="list1" Width="150" Height="200" BorderBrush="{x:Null}" ItemTemplate="{StaticResource dt1}" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Hidden">

<ListBox.Style>
<Style>
<Style.Triggers>
<EventTrigger RoutedEvent="ListBox.Loaded">
<EventTrigger.Actions>
<BeginStoryboard Name="MyBeginStoryboard">
<Storyboard Storyboard.TargetProperty="(Canvas.Top)">
<DoubleAnimation From ="220" To ="-250" RepeatBehavior="Forever" Duration="0:0:5"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="ListBox.MouseMove">
<EventTrigger.Actions>
<PauseStoryboard BeginStoryboardName="MyBeginStoryboard" />
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="ListBox.MouseLeave">
<EventTrigger.Actions>
<ResumeStoryboard BeginStoryboardName="MyBeginStoryboard" />
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</ListBox.Style>
</ListBox>
</Canvas>

Thanks lee d

Chidu
If you bind the ListBox to an ObservableCollection<Whatever> then you can hook it's CollectionChanged event. In that event handler, if you notice that an item was added to the collection, call ScrollIntoView on the ListBox, passing in the new item.


Josh Smith - http://www.infusionblogs.com/blogs/jsmith/default.aspx
Josh Smith

you can try using a timer

System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();

<DataTemplate x:Key="dt1">

<TextBlock Text="{Binding}" Height="30"></TextBlock>

</DataTemplate>

<Canvas>

<ListBox Name="list1" ItemTemplate="{StaticResource dt1}" Height="77" ScrollViewer.VerticalScrollBarVisibility="Hidden" Canvas.Left="100" Canvas.Top="200">

</ListBox>

</Canvas>

void

lee d

ScrollIntoView will provide some functionality, but if you want better control over how the text animates, its speed, direction, etc you might consider creating a small animation framework for your elements. It's fairly simple to create some animated scrolling control containers that will scroll any elements inside of it. I created one called ScrollingCanvas Container which you can find an example and source code for over at xamlXaml.com: http://xamlxaml.com/2006/09/27/scroll-text-and-almost-anything-else-with-the-scrollingcanvas-container/



Michael G. Emmons
http://xamlXaml.com


Michael G. Emmons
Michael G. Emmons
reply 6

You can use google to search for other answers

 

More Articles

• WPF Architectural Question
• Nested WinFX Custom Controls
• Window Management
• loop Media element
• xmlns deisgner versus compiler assembly resolving
• Globalization & Localization
• How to auto-size ListView column headers (without resorting to ha...
• Event registration fails with No error or Exception - Bad Bug
• Disable page input during asynchronous process
• Using an image as a repeating background
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• dragging a grid - problem with positioning
• Video playback frame rate and performance
• ClickOnce Installation
• ScaleTransform a Visual to create reflec
• ItemsControl + FishEyePanel
• DataGrid control
• XamlParseException Error
• Vertical lines in the GridView
• Applying a style to the child items of a
• VS 2005 Extensions for .NET 3.0 RC1
• MasterPages in WPF
• Resize Elements inside the canvas
• xbap security issue with images
• possible 3D LookDirection bug
• Disable Antialiasing

Hot Articles

• Binding the TabItem Content
• LocBaml doesn't work with RC1?
• How can I select all content of a textbo
• Render buttons without border
• Z-order
• Assigning EventTrigger.RoutedEvent to a
• How can I control the internal WebBrowse
• ComboBox and ContextMenu behavior on Tra
• Dual Monitors .. slow
• How to host web browser control
• How to use multiple filters on Items? (B
• debugging XBAP - Http Invocation
• Suggestion: Role-based styling
• RichTextBox, turn off the Keyboard-langu
• Bug when MouseLeave Event in ControlTemp

Recommend Articles

• Change style/dependencyproperties on chi
• setting properties after animation was a
• PrintTicket.PageOrientation does not hav
• Binding a resource object TO a dependenc
• PPT Show in XAML
• List View Control Template
• DataGrid
• September CTP dead link?
• Session ID in XBAP
• WPF in Vista OS applications?
• Help me snap to device pixels...
• Disable page input during asynchronous p
• Referencing components.....
• possible 3D LookDirection bug
• Using LocBaml.exe Tool