Silverlight 如何更改故事板中的路径颜色?
这是我为“X”按钮关闭选项卡制作的完整样式。 它起作用了。但我对它不满意 如果您查看Silverlight 如何更改故事板中的路径颜色?,silverlight,xaml,expression-blend,Silverlight,Xaml,Expression Blend,这是我为“X”按钮关闭选项卡制作的完整样式。 它起作用了。但我对它不满意 如果您查看情节提要s,您会注意到我将两个不同的路径s可见性混洗,以实现我的“X”改变颜色的效果。我更愿意进行颜色转换,但似乎无法绑定到Path的Stroke属性 另外,我有TextBlock,这样我的光标就可以在整个方块上触发MouseOver状态。如果我刚刚离开路径-鼠标上方将仅在实际的路径s颜色上触发。有没有办法让那部分更专业 <Style x:Key="CloseTabButtonStyle" TargetTy
情节提要
s,您会注意到我将两个不同的路径
s可见性混洗,以实现我的“X”改变颜色的效果。我更愿意进行颜色转换,但似乎无法绑定到Path的Stroke
属性
另外,我有TextBlock
,这样我的光标就可以在整个方块上触发MouseOver
状态。如果我刚刚离开路径
-鼠标上方
将仅在实际的路径
s颜色上触发。有没有办法让那部分更专业
<Style x:Key="CloseTabButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="NormalPath">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="MouseOverPath">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="MouseOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="MouseOverPath">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="NormalPath">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<TextBlock Width="8" Height="8"/>
<Path x:Name="MouseOverPath" Stroke="#67c5e0" StrokeThickness="2" Data="M0,0 L8,8 M8,0 L0,8 z" />
<Path x:Name="NormalPath" Stroke="#9feaff" StrokeThickness="2" Data="M0,0 L8,8 M8,0 L0,8 z" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
看得见的
崩溃
看得见的
崩溃
您必须向下钻取笔刷级别以更改笔划颜色。下面是一个简化的动画,演示了如何使用
<Storyboard x:Name="Storyboard1">
<ColorAnimationUsingKeyFrames
Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)"
Storyboard.TargetName="path">
<EasingColorKeyFrame KeyTime="0" Value="Black"/>
<EasingColorKeyFrame KeyTime="0:0:2.9" Value="Yellow"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>