animate listbox items to scrollhow to animate listbox items to scroll and fade out© 2009 Microsoft Corporation. All rights reserved.Thu, 19 Jun 2008 00:15:52 Z6572f731-cb4d-4bfb-8196-62665d2a6e64http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6572f731-cb4d-4bfb-8196-62665d2a6e64#6572f731-cb4d-4bfb-8196-62665d2a6e64http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6572f731-cb4d-4bfb-8196-62665d2a6e64#6572f731-cb4d-4bfb-8196-62665d2a6e64Chiduhttp://social.msdn.microsoft.com/Profile/en-US/?user=Chiduanimate listbox items to scrollhow to animate listbox items to scroll and fade outThu, 05 Oct 2006 14:32:32 Z2006-10-05T14:32:32Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6572f731-cb4d-4bfb-8196-62665d2a6e64#3bc3176d-fd00-46dd-9500-54f6c6db586bhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6572f731-cb4d-4bfb-8196-62665d2a6e64#3bc3176d-fd00-46dd-9500-54f6c6db586blee dhttp://social.msdn.microsoft.com/Profile/en-US/?user=lee%20danimate listbox items to scrollCan you give some more detailsThu, 05 Oct 2006 14:44:27 Z2006-10-05T14:44:27Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6572f731-cb4d-4bfb-8196-62665d2a6e64#9ca5513c-baf6-4721-9802-ec99f901570ahttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6572f731-cb4d-4bfb-8196-62665d2a6e64#9ca5513c-baf6-4721-9802-ec99f901570aChiduhttp://social.msdn.microsoft.com/Profile/en-US/?user=Chiduanimate listbox items to scrolli 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?? <p>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</p> <p>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.</p> <p>&lt;DataTemplate x:Key=&quot;dt1&quot;&gt;<br>&lt;TextBlock Height=&quot;30&quot;&gt;<br>&lt;TextBlock Text=&quot;{Binding}&quot;/&gt;<br>&lt;/Hyperlink&gt;<br>&lt;/TextBlock&gt;<br>&lt;/DataTemplate&gt;<br>&lt;/Window.Resources&gt;</p> <p>&lt;Canvas Width=&quot;150&quot; Height=&quot;200&quot;&gt;<br>&lt;ListBox Name=&quot;list1&quot; Width=&quot;150&quot; Height=&quot;200&quot; BorderBrush=&quot;{x:Null}&quot; ItemTemplate=&quot;{StaticResource dt1}&quot; ScrollViewer.CanContentScroll=&quot;True&quot; ScrollViewer.VerticalScrollBarVisibility=&quot;Hidden&quot;&gt;</p> <p>&lt;ListBox.Style&gt;<br>&lt;Style&gt;<br>&lt;Style.Triggers&gt;<br>&lt;EventTrigger RoutedEvent=&quot;ListBox.Loaded&quot;&gt;<br>&lt;EventTrigger.Actions&gt;<br>&lt;BeginStoryboard Name=&quot;MyBeginStoryboard&quot;&gt;<br>&lt;Storyboard Storyboard.TargetProperty=&quot;(Canvas.Top)&quot;&gt;<br>&lt;DoubleAnimation From =&quot;220&quot; To =&quot;-250&quot; RepeatBehavior=&quot;Forever&quot; Duration=&quot;0:0:5&quot;&gt;&lt;/DoubleAnimation&gt;<br>&lt;/Storyboard&gt;<br>&lt;/BeginStoryboard&gt;<br>&lt;/EventTrigger.Actions&gt;<br>&lt;/EventTrigger&gt;<br>&lt;EventTrigger RoutedEvent=&quot;ListBox.MouseMove&quot;&gt;<br>&lt;EventTrigger.Actions&gt;<br>&lt;PauseStoryboard BeginStoryboardName=&quot;MyBeginStoryboard&quot; /&gt;<br>&lt;/EventTrigger.Actions&gt;<br>&lt;/EventTrigger&gt;<br>&lt;EventTrigger RoutedEvent=&quot;ListBox.MouseLeave&quot;&gt;<br>&lt;EventTrigger.Actions&gt;<br>&lt;ResumeStoryboard BeginStoryboardName=&quot;MyBeginStoryboard&quot; /&gt;<br>&lt;/EventTrigger.Actions&gt;<br>&lt;/EventTrigger&gt;<br>&lt;/Style.Triggers&gt;<br>&lt;/Style&gt; <br>&lt;/ListBox.Style&gt;<br>&lt;/ListBox&gt;<br>&lt;/Canvas&gt;</p> <p>Thanks lee d</p> <p> </p>Thu, 05 Oct 2006 17:11:30 Z2006-10-05T17:11:30Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6572f731-cb4d-4bfb-8196-62665d2a6e64#4533c619-32ae-4621-99d7-154e132f9154http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6572f731-cb4d-4bfb-8196-62665d2a6e64#4533c619-32ae-4621-99d7-154e132f9154Josh Smithhttp://social.msdn.microsoft.com/Profile/en-US/?user=Josh%20Smithanimate listbox items to scrollIf you bind the ListBox to an ObservableCollection&lt;Whatever&gt; 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.Thu, 05 Oct 2006 21:25:11 Z2006-10-05T21:25:11Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6572f731-cb4d-4bfb-8196-62665d2a6e64#516b683b-42e6-4039-a48e-b22b0f06ced4http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6572f731-cb4d-4bfb-8196-62665d2a6e64#516b683b-42e6-4039-a48e-b22b0f06ced4lee dhttp://social.msdn.microsoft.com/Profile/en-US/?user=lee%20danimate listbox items to scroll<p>you can try using a timer</p><font size=2> <p>System.Windows.Threading.</font><font color="#008080" size=2>DispatcherTimer</font><font size=2> timer = </font><font color="#0000ff" size=2>new</font><font size=2> System.Windows.Threading.</font><font color="#008080" size=2>DispatcherTimer</font><font size=2>();</font></p><font color="#0000ff" size=2> <p>&lt;</font><font color="#800000" size=2>DataTemplate</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>x:Key</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>dt1</font><font size=2>&quot;</font><font color="#0000ff" size=2>&gt;</p> <p>&lt;</font><font color="#800000" size=2>TextBlock</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>Text</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>{Binding}</font><font size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>Height</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>30</font><font size=2>&quot;</font><font color="#0000ff" size=2>&gt;&lt;/</font><font color="#800000" size=2>TextBlock</font><font color="#0000ff" size=2>&gt;</p> <p>&lt;/</font><font color="#800000" size=2>DataTemplate</font><font color="#0000ff" size=2>&gt;</font></p><font color="#0000ff" size=2><font color="#0000ff" size=2> <p>&lt;</font><font color="#800000" size=2>Canvas</font><font color="#0000ff" size=2>&gt;</p> <p>&lt;</font><font color="#800000" size=2>ListBox</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>Name</font><font color="#0000ff" size=2>=</font><font color="#000000" size=2>&quot;</font><font color="#0000ff" size=2>list1</font><font color="#000000" size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>ItemTemplate</font><font color="#0000ff" size=2>=</font><font color="#000000" size=2>&quot;</font><font color="#0000ff" size=2>{StaticResource dt1}</font><font color="#000000" size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>Height</font><font color="#0000ff" size=2>=</font><font color="#000000" size=2>&quot;</font><font color="#0000ff" size=2>77</font><font color="#000000" size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>ScrollViewer.VerticalScrollBarVisibility</font><font color="#0000ff" size=2>=</font><font color="#000000" size=2>&quot;</font><font color="#0000ff" size=2>Hidden</font><font color="#000000" size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>Canvas.Left</font><font color="#0000ff" size=2>=</font><font color="#000000" size=2>&quot;</font><font color="#0000ff" size=2>100</font><font color="#000000" size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>Canvas.Top</font><font color="#0000ff" size=2>=</font><font color="#000000" size=2>&quot;</font><font color="#0000ff" size=2>200</font><font color="#000000" size=2>&quot;</font><font color="#0000ff" size=2>&gt;</p> <p></p> <p>&lt;/</font><font color="#800000" size=2>ListBox</font><font color="#0000ff" size=2>&gt;</p> <p>&lt;/</font><font color="#800000" size=2>Canvas</font><font color="#0000ff" size=2>&gt;</p></font></font> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">void</span><span style="font-size:10pt;font-family:'Courier New'"> Window2_Loaded(<span style="color:blue">object</span> sender, <span style="color:teal">RoutedEventArgs</span> e)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">        </span>{</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">for</span> (<span style="color:blue">int</span> i = 0; i &lt; 10; i++)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>list1.Items.Add(<span style="color:maroon">&quot; Item .....&quot;</span> + i.ToString());</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>timer.Interval = <span style="color:teal">TimeSpan</span>.FromSeconds(3);</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>timer.Tick += <span style="color:blue">new</span> <span style="color:teal">EventHandler</span>(timer_Tick);</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>timer.Start();</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">        </span>}</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">        </span><span style="color:blue">int</span> index = 0;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">        </span><span style="color:blue">void</span> timer_Tick(<span style="color:blue">object</span> sender, <span style="color:teal">EventArgs</span> e)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">        </span>{</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">if</span> (index &gt;= list1.Items.Count)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>index = 0;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">       </span><span style="">  </span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>list1.ScrollIntoView(list1.Items[index]);</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>index += 3;</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:10pt;line-height:115%;font-family:'Courier New'"><span style="">        </span>}</span></p> <p> <p>you can make the items to be hyperlinks( <a title="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=786543&amp;SiteID=1" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=786543&amp;SiteID=1">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=786543&amp;SiteID=1</a> )</p> <p>you can template the listbox to have 2 buttons, when clicked will effectively call the logic to do the samething as timer_tick</p></p>Fri, 06 Oct 2006 09:16:37 Z2006-10-06T09:16:37Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6572f731-cb4d-4bfb-8196-62665d2a6e64#0a1c6ca0-8638-4e84-b74a-0b3450745dc1http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6572f731-cb4d-4bfb-8196-62665d2a6e64#0a1c6ca0-8638-4e84-b74a-0b3450745dc1Michael G. Emmonshttp://social.msdn.microsoft.com/Profile/en-US/?user=Michael%20G.%20Emmonsanimate listbox items to scroll<p>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: <a title="http://xamlxaml.com/2006/09/27/scroll-text-and-almost-anything-else-with-the-scrollingcanvas-container/" href="http://xamlxaml.com/2006/09/27/scroll-text-and-almost-anything-else-with-the-scrollingcanvas-container/">http://xamlxaml.com/2006/09/27/scroll-text-and-almost-anything-else-with-the-scrollingcanvas-container/</a></p><br><br>Michael G. Emmons <br>http://xamlXaml.comFri, 06 Oct 2006 15:25:15 Z2006-10-06T15:25:15Z