我正在处理新闻Feed。这将经常更新,如果找到新项目,我想从顶部滑入新内容。
现在,我只是通过以下方式让它消失:
<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>
这很好用,但我真的想把这个项目放进去。我已经尝试了所有可能找到的东西,无法到达任何地方。任何帮助将不胜感激。
答案 0 :(得分:37)
这是你要找的吗?
<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>