我正在尝试绑定 ColorAnimation TO={Binding Source={StaticResource Test1}, Path=Color}
我可以使用 SolidColorBrush 执行此操作,但在尝试在彩色动画中使用它时出现“System.Windows.Markup.XamlParseException”异常。
这是我所拥有的:
<SolidColorBrush x:Key="Test1" Color="{Binding Source={x:Static self:MySettings.Default}, Path=HighlightColor}"/>
<SolidColorBrush x:Key="Test2" Color="{Binding Source={x:Static self:MySettings.Default}, Path=TextColor}"/>
<Style x:Key="WindowLabel" TargetType="Border" BasedOn="{StaticResource HighlightBorder}">
<Setter Property="Background" Value="{StaticResource Test2}"/>
<Setter Property="Height" Value="50"/>
<Style.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard>
<Storyboard>
<ColorAnimation To="{Binding Source={StaticResource Test1}, Path=Color}"
Duration="{StaticResource AnimSpeed}"
Storyboard.TargetProperty="Background.Color"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<BeginStoryboard>
<Storyboard>
<ColorAnimation To="{Binding Source={StaticResource Test2}, Path=Color}"
Duration="{StaticResource AnimSpeed}"
Storyboard.TargetProperty="Background.Color"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
Test2 SolidColorBrush 工作正常,那么为什么动画不能呢?