1
votes

I have an application that uses themes to customize the appearance of buttons and other ui controls. The styles use some common colors so they are defined in xaml and referenced with StaticResource:

<ColorAnimation Storyboard.TargetName="LayoutRoot"
                Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
                To="{StaticResource AccentColor}"
                Duration="00:00:00"/>

Now, i'd like to make AccentColor configurable. The problem is that here i can't just use a DynamicResource because ColorAnimation must be freezable to be used in storyboards.

Is there a workaround for this?

1

1 Answers

2
votes

It seems that the only workaround is to not use ColorAnimation but 2 elements, one of which has the background set to {DynamicResource AccentColor} and swap their visibility.

Of course this workaround is specific to this case, for example it only makes sense if the ColorAnimation duration is 0, otherwise it doesn't give the same visual effect.