Problem with multiple EventTriggers on RoutedEvent="Binding.TargetUpdated" where both events are fired when one binding is updated

15 views Asked by At

I have a ContentControl bound to a property containing a ViewModel. When the ViewModel property changes I want the Content to 'slide in' as follows

                <ContentControl x:Name="outerContent" Content="{Binding CurrentVM, NotifyOnTargetUpdated=True}" >
                    <ContentControl.Resources>
                        <DataTemplate DataType="{x:Type InnerViewModel}">
                            <InnerView/>
                        </DataTemplate>
                    </ContentControl.Resources>
                    <ContentControl.Triggers>
                        <EventTrigger RoutedEvent="Binding.TargetUpdated" SourceName="webcamContent">
                            <BeginStoryboard>
                                <Storyboard AutoReverse="False" Completed="StartAnimation_Completed">
                                    <ThicknessAnimation Storyboard.TargetProperty="Margin" BeginTime="00:00:00" Duration="00:00:00.3" DecelerationRatio="0.7"
                                                        To="{Binding CurrentVM.PageTransitionDirection, Converter={StaticResource ToAnimationConverter}}" 
                                                        From="{Binding CurrentVM.PageTransitionDirection, Converter={StaticResource FromAnimationConverter}}">
                                    </ThicknessAnimation>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </ContentControl.Triggers>
                </ContentControl>

InnerViewModel is pretty irrelevant except that it exposes another property also called CurrentVM (that share a common base class) with a third ViewModel. InnerView follows a similar structure including another ContentControl

                <ContentControl x:Name="innerContent" Content="{Binding CurrentVM, NotifyOnTargetUpdated=True}" >
                    <ContentControl.Resources>
                        <DataTemplate DataType="{x:Type AAnotherViewModel}">
                            <AAnotherView/>
                        </DataTemplate>
                    </ContentControl.Resources>
                    <ContentControl.Triggers>
                        <EventTrigger RoutedEvent="Binding.TargetUpdated" SourceName="webcamContent">
                            <BeginStoryboard>
                                <Storyboard AutoReverse="False" Completed="StartAnimation_Completed">
                                    <ThicknessAnimation Storyboard.TargetProperty="Margin" BeginTime="00:00:00" Duration="00:00:00.3" DecelerationRatio="0.7"
                                                        To="{Binding CurrentVM.PageTransitionDirection, Converter={StaticResource ToAnimationConverter}}" 
                                                        From="{Binding CurrentVM.PageTransitionDirection, Converter={StaticResource FromAnimationConverter}}">
                                    </ThicknessAnimation>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </ContentControl.Triggers>
                </ContentControl>

So my problem is when the Property CurrentVM of InnerViewModel is updated both the Storyboards fire, not just the Storyboard of the InnerView

0

There are 0 answers