Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 标签上的字符串动画_Wpf_Templates_Animation_Wpf Controls_Controltemplate - Fatal编程技术网

Wpf 标签上的字符串动画

Wpf 标签上的字符串动画,wpf,templates,animation,wpf-controls,controltemplate,Wpf,Templates,Animation,Wpf Controls,Controltemplate,我有一个指示操作模式的控件。根据当前模式“自动”、“手动”或“无”,它会向左或向右旋转几度,并更改标签的内容。旋转已经可以正常工作了。但无论当前状态如何,标签的内容都不会显示。控件模板中是否有任何错误?我通过删除第三个状态将模板简化了一点?或者还有什么不应该的吗 提前谢谢 <ControlTemplate TargetType="{x:Type local:OperationModeIndicator}"> <Grid x:Name="rootGrid" RenderT

我有一个指示操作模式的控件。根据当前模式“自动”、“手动”或“无”,它会向左或向右旋转几度,并更改标签的内容。旋转已经可以正常工作了。但无论当前状态如何,标签的内容都不会显示。控件模板中是否有任何错误?我通过删除第三个状态将模板简化了一点?或者还有什么不应该的吗

提前谢谢

<ControlTemplate TargetType="{x:Type local:OperationModeIndicator}">
    <Grid x:Name="rootGrid" RenderTransformOrigin="0.5,0.525">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="OperationModeStates">
                <VisualState x:Name="None">
                    <Storyboard>
                        <StringAnimationUsingKeyFrames Storyboard.TargetName="contentLabel" Storyboard.TargetProperty="Content" >
                            <DiscreteStringKeyFrame Value="" />
                        </StringAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)" Storyboard.TargetName="rootGrid" >
                            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)" Storyboard.TargetName="contentLabel">
                            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Automatic">
                    <Storyboard>
                        <StringAnimationUsingKeyFrames Storyboard.TargetName="contentLabel" Storyboard.TargetProperty="Content" >
                            <DiscreteStringKeyFrame Value="A" />
                        </StringAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)" Storyboard.TargetName="rootGrid">
                            <EasingDoubleKeyFrame KeyTime="0" Value="-30"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)" Storyboard.TargetName="contentLabel">
                            <EasingDoubleKeyFrame KeyTime="0" Value="30"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Grid.RenderTransform>
            <TransformGroup>
                <RotateTransform/>
            </TransformGroup>
        </Grid.RenderTransform>
        <Label x:Name="contentLabel" Foreground="#FFDA1D1D" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="48" RenderTransformOrigin="0.5,0.525" >
            <Label.RenderTransform>
                <TransformGroup>
                    <RotateTransform/>
                </TransformGroup>
            </Label.RenderTransform>
        </Label>
        <Path Stroke="Gray" StrokeThickness="5">
            <Path.Data>
                <PathGeometry>
                    <PathFigure StartPoint="35 10" >
                        <ArcSegment Point="65 10" Size="45 45" RotationAngle="0" IsLargeArc="True" />
                    </PathFigure>
                </PathGeometry>
            </Path.Data>
        </Path>
        <Line X1="2.5" X2="2.5" Y1="0" Y2="20" StrokeThickness="5" Stroke="Gray" HorizontalAlignment="Center" />
    </Grid>
</ControlTemplate>

动画按预期工作。这是一种没有表现出来的混合物。无论如何,原因仍然不明