2010-11-03 63 views
1

我在Silverlight中構建了Windows Phone 7應用程序。在Silverlight 4中執行此動畫的最佳方法是什麼?

我有一個ListBox內容列表。當用戶按下一個按鈕時,列表中每個項目旁邊應出現「刪除」圖標。理想情況下,列表項會滑過,圖標將被動畫。

我不確定要做這件事的最佳方法是什麼。我不熟悉Silverlight中的動畫。一種方法:爲包含圖標和實際內容的ListBox製作數據模板。如果用戶點擊該按鈕,則切換圖標的可見性。將事件處理程序附加到正在點擊的圖標上。 (我不知道如何將動畫加入到這個中。)

或者還有其他方法可以使這項工作?

更新:好吧,我有一個漂亮的動畫,其中內容滑出和背部。不過,我想爲列表中的每個項目添加一個圖標。我怎樣才能做到這一點?

<VisualStateManager.CustomVisualStateManager> 
      <ic:ExtendedVisualStateManager/> 
     </VisualStateManager.CustomVisualStateManager> 
     <VisualStateManager.VisualStateGroups> 
      <VisualStateGroup x:Name="EditingStates"> 
       <VisualStateGroup.Transitions> 
        <VisualTransition GeneratedDuration="0:0:1"/> 
       </VisualStateGroup.Transitions> 
       <VisualState x:Name="Editing"> 
        <Storyboard> 
         <DoubleAnimation Duration="0" To="60" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="pivotItem" d:IsOptimized="True"/> 
        </Storyboard> 
       </VisualState> 
       <VisualState x:Name="NotEditing"> 
        <Storyboard> 
         <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="pivotItem" d:IsOptimized="True"/> 
        </Storyboard> 
       </VisualState> 
      </VisualStateGroup> 
     </VisualStateManager.VisualStateGroups> 

而且,現在這是硬編碼爲一個特定的控制。如何將其更改爲用戶當前正在查看的pivotItem

+0

你有用於Windows Phone的Expression Blend嗎? Blend使創建動畫非常簡單。 – 2010-11-03 20:01:09

+0

我的確有Expression Blend。 – 2010-11-03 20:33:41

+0

Windows Phone 7沒有使用Silverlight 4(在您的問題的標題中提到),而是Silverlight 3中的某些電話特定的添加/排除。 – peSHIr 2010-11-10 14:48:20

回答

2

這是VisualStates的「規範」情況 - 只創建一個狀態,圖標打開,圖標關閉,並在它們之間切換。國家之間的動畫可以很容易地完成。我建議你使用的WP7(免費)混合,並檢查該視頻爲出發點:

http://expression.microsoft.com/en-us/ee426922.aspx

編輯:

對於你的問題的第2部分,只需將圖標到ItemTemplate,並使其從外部滑動和/或使用VS動畫增長(改變寬度/高度)。

您應該將VisualStates添加到ListBox中的項目模板中;通過這樣做,您將能夠在VS動畫中引用控件和圖標的正確實例。

+0

您可以顯示一些示例XAML以瞭解如何使用視覺狀態動畫項目模板? – 2010-11-12 20:06:12

1

在列表框控件中使用故事板,如果您沒有想法,請嘗試使用Expression Blend for Windows Phone 7,然後添加一個關鍵幀,就像Adobe Flash一樣。

相關問題