I think the main reason is sealed objects. If you have a style hierarchy:
Style A / \ Style A1 Style A2
this may not be a complicated scenario. You reference StyleA using a dynamic resource, so when this resource changes, Style A1 and Style A2 must change their BasedOn property. However, as soon as the style is used in your application, it becomes a sealed object. Style A becomes unchanged.
One workaround you can use is:
Style A needs to be changed.- Create a new Style object that will become the new
Style A resource. - Create a new version of
Style A1 and Style A2 . You will need to write a copy procedure that will make copies of all Setters , Resources , etc. Install BasedOn in the new version of Style A - Update your resource collection to have three new styles.
{DynamicResource StyleA1} and {DynamicResource StyleA2} should now understand that these resources change (from step 4) and automatically update any links.
Please note that this is a very simple scenario. Real-world style hierarchies can be more complex, especially if they are distributed across multiple files and come from merged dictionaries.
Hope I understood your problem and helped.
Szymon Rozga Feb 25 '09 at 14:37 2009-02-25 14:37
source share