【问题标题】:Stackpanel add item animationStackpanel 添加项目动画
【发布时间】:2010-02-19 14:52:13
【问题描述】:

我一直在为选取框式图像滚动控件苦苦挣扎。

有一段时间,我坚持使用模板化的 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 绑定到 ObservableCollection,所以我可以在运行时添加项目。一旦项目离开屏幕,它就会从 ObservableCollection 中删除。

最后要做的是实现自定义项目添加行为(平滑滑入而不是插入翻译其他行为)。 我应该从 StackPanel 派生来实现这样的效果,还是只对当前添加的项目执行 DoubleAnimation? 任何建议表示赞赏。

【问题讨论】:

    标签: wpf scroll slide stackpanel itemscollection


    【解决方案1】:

    看看这个:Animate WPF Datatemplate when item added to Listbox。它会满足您的需求吗?

    【讨论】:

    • 谢谢,我一直在寻找。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-05
    • 2019-07-03
    • 2019-04-12
    • 1970-01-01
    相关资源
    最近更新 更多