ListBox Slide Animation On New Item Added

后端 未结 1 683
旧时难觅i
旧时难觅i 2020-12-24 09:56

I am working on a news feed. This will update every so often and if new items are found, I want to slide in the new content from the top.

Right now, I am just having

相关标签:
1条回答
  • 2020-12-24 10:46

    Is this what you're looking for?

     <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 讨论(0)
提交回复
热议问题