简体   繁体   中英

Why my WPF animation starts just once?

I have an animation that works fine the first time it is triggered, but when the GoNextCmd is raising to true a second time, the animation doesn't start anymore. Here is my code :

<ItemsControl DockPanel.Dock="Top" ItemsSource="{Binding ViewCollection}" x:Name="itemsControl">

    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal"></StackPanel>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>

    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <ContentControl Content="{Binding}" Width="500" Name="toMove">
            </ContentControl>
        </DataTemplate>
    </ItemsControl.ItemTemplate>

    <ItemsControl.Style>
        <Style TargetType="ItemsControl">
            <Style.Triggers>
                <DataTrigger Binding="{Binding GoNextCmd}" Value="true">
                    <DataTrigger.EnterActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <ThicknessAnimation RepeatBehavior="1x" FillBehavior="Stop" Storyboard.TargetProperty="Margin" By="-250,0,0,0" Duration="0:0:1">
                                    <ThicknessAnimation.EasingFunction>
                                        <QuinticEase EasingMode="EaseInOut" />
                                    </ThicknessAnimation.EasingFunction>
                                </ThicknessAnimation>                               
                            </Storyboard>
                        </BeginStoryboard>
                    </DataTrigger.EnterActions>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </ItemsControl.Style>

</ItemsControl>

Does somebody knows something about it?

我不确定命令升为true的意思,但是使用DataTriggers时,应该使用INotifyPropertyChanged使用属性(使用setter时升高PropertyChanged)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM