13

我正在处理新闻提要。这会经常更新,如果发现新项目,我想从顶部滑入新内容。

现在,我只是通过执行以下操作让它淡入淡出:

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

这很好用,但我真的很想把这个项目滑进去。我已经尝试了我能找到的所有可能的东西,但无法到达任何地方。任何帮助将非常感激。

4

1 回答 1

44

这是你要找的吗?

 <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>
于 2012-10-24T02:50:53.937 回答