模板中的动画未使用路径更新为动画

时间:2012-11-13 14:50:57

标签: wpf arcgis esri

我有以下XAML,它为在ESRI Map控件的路径上移动的箭头设置动画。动画按预期工作,但地图放大或缩小时动画不会失效。如果我将动画移出屏幕并返回屏幕,则动画会正确地重新同步到缩放路径。当地图比例改变时,如何设置触发器以强制重绘?

<esri:LineSymbol x:Key="tunnelSymbol">
    <esri:LineSymbol.ControlTemplate>
        <ControlTemplate>
            <Canvas>
                <Path x:Name="Element" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeDashCap="Round" StrokeLineJoin="Round" Opacity="0.5" RenderTransformOrigin="2,0" StrokeThickness="5" Stroke="#FF05AA05">
                    <Path.Effect>
                        <DropShadowEffect/>
                    </Path.Effect>
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="SelectionStates">
                            <VisualState x:Name="Selected">
                            </VisualState>
                            <VisualState x:Name="Unselected"/>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Normal">
                                <Storyboard>
                                    <DoubleAnimation BeginTime="0" Duration="0:0:0.1" Storyboard.TargetName="Element" Storyboard.TargetProperty="(Path.StrokeThickness)" To="5"/>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="MouseOver">
                                <Storyboard>
                                    <DoubleAnimation BeginTime="0" Duration="0:0:0.1" Storyboard.TargetName="Element" Storyboard.TargetProperty="(Path.StrokeThickness)" To="10"/>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                </Path>
                <Path x:Name="Arrow" Stretch="Fill" Width="16" Height="16" StrokeLineJoin="Miter"
                      Data="M 0 -5 L 10 -5 M 5 0 L 10 -5 L 5 -10"
                      Stroke="Black" StrokeThickness="3">
                    <Path.RenderTransform>
                        <TransformGroup>
                            <TranslateTransform X="-8" Y="-8"/>
                            <MatrixTransform>
                                <MatrixTransform.Matrix>
                                    <Matrix/>
                                </MatrixTransform.Matrix>
                            </MatrixTransform>
                        </TransformGroup>
                    </Path.RenderTransform>
                    <Path.Triggers>
                        <EventTrigger RoutedEvent="Path.Loaded">
                            <BeginStoryboard>
                                <Storyboard>
                                    <MatrixAnimationUsingPath x:Name="MatrixAnimation" Storyboard.TargetName="Arrow"
                                                              Storyboard.TargetProperty="RenderTransform.Children[1].Matrix"
                                                              DoesRotateWithTangent="True"
                                                              Duration="0:0:5"
                                                              BeginTime="0:0:0"
                                                              RepeatBehavior="Forever" PathGeometry="{Binding Data, Source=Element, BindsDirectlyToSource=True}">
                                    </MatrixAnimationUsingPath>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </Path.Triggers>
                </Path>
            </Canvas>
        </ControlTemplate>
    </esri:LineSymbol.ControlTemplate>
</esri:LineSymbol>

0 个答案:

没有答案