I'm trying to decide if this might be a good idea to help reduce the size of some of my xaml resource dictionaries on a large project. Except I'm concerned about any potential performance issues going this route so hoping to get some insight from other technically proficient folks.
So as example, say there's dozens of control Style
templates which I've standardized to use shared naming conventions in their objects and handling. To make it a more clear example say you have things like Buttons/TextBoxes/GridSplitters/CheckBoxes etc etc etc.
They all have their own Style template, but they all would have say a Border
which is Collapsed by default but each has the same Visibility toggling DoubleAnimation
in their respective Storyboard
for the MouseOver state as defined in the VisualStateManager
Which basically makes the exact same repeated DoubleAnimation
over and over for dozens of controls for that MouseOver state.
My question is could I potentially negatively impact performance if I made each of these overly repetitive Storyboards
into their own resource so instead of repeating the same thing over and over again on each style template like;
<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimation .../>
</Storyboard>
</VisualState>
Could I instead take that currently repeated exact same Storyboard
and do something like this with out negatively impacting (and hopefully actually even improving) the performance of such a large project like;
<Storyboard x:Name="TheRepetitiveAnimation">
<DoubleAnimation ..../>
</Storyboard>
Then on each instance in each template instead of having the whole animation repeated I could just do;
<VisualState x:Name="MouseOver>
<BeginStoryboard Storyboard="{StaticResource TheRepetitiveAnimation"/>
</VisualState>
Because if I could do it this way, I could probably shave at minimum another thousand lines out of my resource dictionaries by exchanging the multi-line repeated animations with a one line reference to a master Storyboard
that way.
Except I'm concerned doing this for so many control templates calling back to reference the same storyboard for all of the same instance might produce opposite results of what I'm trying to do. Which is simply to reduce the size/footprint of all the XAML and hopefully even speed things up in the process.
Any thoughts welcome, cheers.