第一次加载控件时,我在设置故事板动画时遇到问题。加载后,如果我将其IsEnabled更改为true或false,则它可以正常工作。我想知道这是否有效。但是同样的基础在Windows手机应用程序中运行得很好。
<Button Style="{StaticResource SyncBtnStyle}" Tag="/Assets/topicon_refresh.png"
IsEnabled="False" />
<Style x:Key="SyncBtnStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="FontFamily" Value="Segoe UI Symbol"/>
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="FontSize" Value="56"/>
<Setter Property="Padding" Value="10,5,10,6"/>
<Setter Property="Height" Value="40"/>
<Setter Property="Width" Value="40"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Background="Transparent">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver"/>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BgEllipse">
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard RepeatBehavior="Forever">
<DoubleAnimation Duration="0:0:1" To="360" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="MainImg" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="ButtonBackground" Background="{TemplateBinding Background}" CornerRadius="0">
<Grid>
<Ellipse Fill="Transparent" Margin="4 6 4 4" Opacity="0" x:Name="BgEllipse"/>
<Image x:Name="MainImg" Stretch="Uniform" Source="{Binding Tag, RelativeSource={RelativeSource Mode=TemplatedParent}}" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<CompositeTransform/>
</Image.RenderTransform>
</Image>
</Grid>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
如果我在这里做错了,请帮帮我。