【问题标题】:Sequentially animate items in an ItemsControl在 ItemsControl 中按顺序为项目设置动画
【发布时间】:2009-06-15 11:42:56
【问题描述】:

举个简单的例子,如果你有一个像下面这样动态创建它的内容的 ItemsControl 我如何添加触发器,以便每个项目在列表中动画并具有一个 BeginTime 基于它在列表中的索引。

我已经尝试扩展按钮,使其包含延迟时间,然后绑定按钮 ControlTemplate 的触发器中包含的动画的 BeginTime,因为动画可冻结而存在问题。

如何在 ItemsControl 本身或单个项目上创建一个情节提要,逐个显示每个项目。

有什么想法吗?

我的标记的起点:

<Window.Resources>
    <ResourceDictionary >
        <Collections:ArrayList x:Key="ItemsList">
            <System:String>OPTIONS</System:String>
            <System:String>STICKERS</System:String>
            <System:String>STYLING</System:String>
            <System:String>WHEELS</System:String>
            <System:String>INTERIOR</System:String>
            <System:String>ROOF</System:String>
            <System:String>COLOURS</System:String>
            <System:String>VERSION</System:String>
        </Collections:ArrayList>
    </ResourceDictionary>
</Window.Resources>

<Grid>
    <ListView ItemsSource="{StaticResource ItemsList}">
        <ListView.Style>
            <Style>
                <Setter Property="ListView.ItemTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <Button Content="{Binding}" />
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ListView.Style>
    </ListView>
</Grid>

干杯 J

【问题讨论】:

    标签: c# wpf xaml


    【解决方案1】:

    可能无法通过 XAML 执行此操作。

    相反,在 C# 代码隐藏中填充 ListView,并在代码中创建情节提要和触发器。一个想法是将 Button 扩展为具有“Next Button To Show”字段,播放故事板以显示动画,然后触发下一个按钮执行相同操作,直到到达“NextButton == null”的最后一个按钮

    【讨论】:

    • 是的。我有类似的东西,但我不喜欢动画不能通过资源更改和维护的事实。
    猜你喜欢
    • 2020-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-18
    • 1970-01-01
    • 2013-06-03
    • 2011-10-24
    • 2016-09-18
    相关资源
    最近更新 更多