1

我有以下 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>
4

0 回答 0