From this page, I read:
If your application uses custom controls and defines resources in a ResourceDictionary (or XAML Resources node), it is recommended that you either define the resources at the Application or Window object level, or define them in the default theme for the custom controls. Defining resources in a custom control's ResourceDictionary imposes a performance impact for every instance of that control.
Ok... now, I have a UserControl that defines the following resources:
<UserControl ...>
<UserControl.Resources>
<Namespace:ImagesConverter x:Key="ImagesConverter" ...
<Storyboard x:Key="AnimationHide" ...
</UserControl.Resources>
So, because of the fact I'm creating not less than 100 instances of them at runtime, as the MSDN tutorial says, it would be better to move those resources ad MainWindow or App level. Where's the best location to move them to? MainWindow level, App level or resource file? And why?
And then... how can I use them from their new location? Let's say I have this code inside my UserControl:
m_AnimationHide = (Storyboard)Resources["AnimationHide"];
How should I modify it to reflect those changes? And how should I modify the following UserControl XAML snippet instead?
Source="{Binding Source={x:Static Properties:Resources.MyImage}, Converter={StaticResource ImagesConverter}}"