Search code examples
silverlightcoding-styleclone

Is there any convinient way that i can deepclone 'style' instance in silverlight?


if a style is used, it can not be modified agaign. so i need a clone method. but its hard to implement.

what i want to do is implementing a cascading 'style' mechanism. for example, i set two style to the same frameworkelement. the same property of latter style will override the former one, while the different property remain unchanged. but if i set the style property of the frameworkelement twice directly, the 1st style will be gone. so i use the baseon property of style class to do that. but now come across another problem, the style can not be modified after it's been set to a frameworkelement. so now i need a clone method.


Solution

  • Kevin,

    I have written a CloneObject class which is exactly what you are looking for. Check out my code here:

    "Generic class for deep clone of Silverlight and C# objects".

    Jim