2012-10-23 17 views
11

私はニュースフィードを作成中です。これは頻繁に更新され、新しいアイテムが見つかった場合は、新しいコンテンツを上からスライドします。ListBoxのスライドアニメーションが新しいアイテムに追加されました

は今、私はちょうどそれが次の操作を行って、フェードインが午前:

<ListBox Grid.Row="0" Height="Auto" HorizontalAlignment="Stretch" Margin="5,5,5,5" VerticalAlignment="Top" ItemsSource="{Binding NewsItems,UpdateSourceTrigger=PropertyChanged}" > 
     <ListBox.ItemContainerStyle>     
      <Style TargetType="{x:Type ListBoxItem}">      
       <Style.Triggers>           
         <EventTrigger RoutedEvent="Loaded"> 
         <EventTrigger.Actions>         
          <BeginStoryboard> 
           <Storyboard>          
            <DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:2" />  
           </Storyboard> 
          </BeginStoryboard> 
         </EventTrigger.Actions> 
        </EventTrigger> 
       </Style.Triggers> 
      </Style> 
      </ListBox.ItemContainerStyle> 
     <ListBox.ItemTemplate>  
     .... 
</ListBox> 

これは正常に動作しますが、私は本当に内のアイテムのスライドを持っていると思い、私は私ができるすべての可能なものを試してみました。見つけてどこにも行けません。どんな助けでも大歓迎です。

答えて

36

これはあなたが探しているものですか?

<ListBox x:Name="lstBox" Grid.Row="0" Height="Auto" HorizontalAlignment="Stretch" Margin="5,5,5,5" VerticalAlignment="Top" ItemsSource="{Binding NewsItems,UpdateSourceTrigger=PropertyChanged}" > 
     <ListBox.ItemContainerStyle> 
      <Style TargetType="{x:Type ListBoxItem}"> 
       <Setter Property="LayoutTransform"> 
        <Setter.Value> 
         <ScaleTransform x:Name="transform" /> 
        </Setter.Value> 
       </Setter> 
       <Style.Triggers> 
        <EventTrigger RoutedEvent="Loaded"> 
         <EventTrigger.Actions> 
          <BeginStoryboard> 
           <Storyboard> 
            <DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:2" /> 
            <DoubleAnimation Storyboard.TargetProperty="LayoutTransform.ScaleY" From="0" Duration="0:0:.2"/> 
           </Storyboard> 
          </BeginStoryboard> 
         </EventTrigger.Actions> 
        </EventTrigger> 
       </Style.Triggers> 
      </Style> 
     </ListBox.ItemContainerStyle> 
    </ListBox> 
+0

これを行いました。私はsetterプロパティの追加を見落としていました。ありがとうございました! – TrialAndError

+0

私はこれを何度もupvoteできますか?シンプルで、まさに私が望んでいたことです!ありがとう! – Darkhydro

+0

これはクールです。残念なことに、UnLoadはアイテムを削除するために同じように動作しません。私はアレンジと測定の呼び出しでカスタムパネルを実装することになりました –

関連する問題