2014-12-19 44 views
0

我有這段代碼工作得很好:啓動時,LstDevices ListView在1秒內變爲透明。Windows Phone 8.1 - 動畫列表視圖項目

private void DoAnimation() 
    { 
     Storyboard s = new Storyboard(); 
     DoubleAnimation doubleAnimation = new DoubleAnimation(); 

     doubleAnimation.To = 0; 
     doubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(1000)); 

     Storyboard.SetTarget(doubleAnimation, LstDevices); 
     Storyboard.SetTargetProperty(doubleAnimation, "Opacity"); 

     s.Children.Add(doubleAnimation); 
     s.Begin(); 
    } 

事實是,我需要這個的ListView做2件不同的事情:

1)動畫ListView控件這樣反而比變得不可見,它應該通過移動關閉屏幕上消失。 2)下一步,如果我滑動單個項目,單個項目應通過移出屏幕消失。

事實是,我無法找到修改我需要移動的項目的X和Y位置的屬性。 任何人有任何想法?

回答

0

我認爲通過使用帶有DoubleAnimation的TranslateTransform來做到這一點最簡單。隨着時間的推移,您可以使用DoubleAnimation更改X和Y值,以顯示移動屏幕外觀。

DoubleAnimation doubleAnimation = new DoubleAnimation();  
itemToAnimate.RenderTransform = (Transform)new TranslateTransform(); 

,然後當我有設定目標

Storyboard.SetTarget((Timeline)doubleAnimation, (DependencyObject)itemToAnimate.RenderTransform); 
+0

謝謝您的回答! 請問,你能提供一些代碼作爲例子嗎? – Ravenheart

+0

找到答案!我用這個 DoubleAnimation doubleAnimation = new DoubleAnimation(); itemToAnimate.RenderTransform =(Transform)new TranslateTransform(); 然後當我必須設置目標 Storyboard.SetTarget((Timeline)doubleAnimation,(DependencyObject)itemToAnimate.RenderTransform); – Ravenheart

+0

很高興聽到這個消息,我正要對此進行研究並找到答案。 –

相關問題