0
votes

I have an animation that works fine the first time it is triggered, but when the GoNextCmdis 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?

1
Did you try it in a clean project? It works fine for me and animation is triggered each time property value is set to true - dkozl
I tried it but it still doesn't work. What is the code you have tested it with? - bobby4078
I've tested your control with simple view model that implements INotifyPropertyChanged which has some simple ViewCollection list and bool GoNextCmd property - dkozl
Hum it seems to be the same that my code... is there a way you can show me your view model code and xaml? - bobby4078
There is really not much of a code to show. One ObservableCollection<string> list property and one bool property. which I change when button is clicked, and INotifyPropertyChanged implementation + your XAML. - dkozl

1 Answers

0
votes

I am not sure what you mean by the command rising to true but with DataTriggers you should be using properties using INotifyPropertyChanged (and rising PropertyChanged when the setter is used).