Stackpanel add item animation
Posted
by grzegorz_p
on Stack Overflow
See other posts from Stack Overflow
or by grzegorz_p
Published on 2010-02-19T14:52:13Z
Indexed on
2010/04/16
14:03 UTC
Read the original article
Hit count: 408
Hello, I've been struggling a while with marquee-style image scrolling control.
At a moment, I stuck up with templated ItemsControl:
<Window.Resources>
<DataTemplate x:Key="itemsTemplate">
<Image Source="{Binding AbsolutePath}"></Image>
</DataTemplate>
</Window.Resources>
<ItemsControl ItemTemplate="{StaticResource itemsTemplate}" x:Name="ic"
ItemsSource="{Binding ElementName=mainWindow, Path=DataItems}" VirtualizingStackPanel.IsVirtualizing="True">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical" VerticalAlignment="Bottom"
VirtualizingStackPanel.IsVirtualizing="True" >
</VirtualizingStackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
ItemsControl is bound to ObservableCollection, so I can add items at runtime. As soon as item goes off-screen it's removed from ObservableCollection.
The last thing to do is implementing custom item add behavior (smooth slide-in instead of insert-translateothers behavior). Shall I derive from StackPanel to achieve such effect or just perform DoubleAnimation on currently adding item? Any suggestions appreciated.
© Stack Overflow or respective owner