2009-06-15 51 views
1

所以作爲一個簡單的例子,如果你有一個像下面那個動態創建它的內容的ItemsControl我怎麼可以添加觸發器,以便每個項目動畫和有一個BeginTime基於它的索引在名單。按順序動畫ItemsControl中的項目

我試過擴展按鈕,使其包含延遲時間,然後綁定按鈕ControlTemplate的觸發器中包含的動畫的BeginTime,由於動畫是可凍結的,因此存在問題。

如何在ItemsControl本身或單個項目上創建一個Storyboard,逐個顯示每個項目。

任何想法?

起點爲我的標記:

<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> 

乾杯 Ĵ

回答

1

有可能是沒有辦法通過XAML來做到這一點。

而是在您的C#代碼隱藏中填充ListView,然後在代碼中創建Storyboard和Trigger。一個想法是將Button擴展爲具有「下一個按鈕顯示」字段,爲您的顯示動畫播放故事板,然後觸發下一個按鈕執行相同操作,直到您到達最後一個按鈕「NextButton == null」

+0

是的。我有這樣的事情,但我不喜歡動畫無法通過資源進行更改和維護的事實。 – 2009-06-17 08:29:40