【发布时间】:2013-12-05 21:44:05
【问题描述】:
有没有办法以 XAML 样式为 TargetType 边框定义情节提要? 这是我想要实现的目标:
<Style x:Key="MyBorderStyle" TargetType="Border">
<Setter Property="VisualStateManager.VisualStateGroups">
<Setter.Value>
<VisualStateGroup>
<VisualStateGroup.States>
<VisualState x:Name="Normal">
<Storyboard RepeatBehavior="Forever">
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Stroke">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PaperDark}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="StrokeThickness">
<DiscreteObjectKeyFrame KeyTime="0" Value="2"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="StrokeDashArray">
<DiscreteObjectKeyFrame KeyTime="0" Value="3, 3"/>
<DiscreteObjectKeyFrame KeyTime="00:00:0.200" Value="3, 3"/>
<DiscreteObjectKeyFrame KeyTime="00:00:0.400" Value="3, 3"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="StrokeDashOffset">
<DiscreteObjectKeyFrame KeyTime="0" Value="3"/>
<DiscreteObjectKeyFrame KeyTime="00:00:0.200" Value="0"/>
<DiscreteObjectKeyFrame KeyTime="00:00:0.400" Value="3"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup.States>
</VisualStateGroup>
</Setter.Value>
</Setter>
</Style>
但这不起作用。
我还尝试了其他几种方法,但无法正常工作。 我想在 MyStyles.XAML 中定义此样式,然后在 MainPage.XAML 中使用它,例如:
<Border Style="{StaticResource MyBorderStyle}">
Some code...
</Border>
请帮忙。
【问题讨论】:
-
您在此处未使用离散情节提要是正确的
标签: windows-store-apps winrt-xaml windows-8.1