Stackpanel add item animation
- by grzegorz_p
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.