views:

53

answers:

0

I have written custom markup extesions, but what if I need to override an markup extension already defined? For example, I need to serialize StaticResources references and not the values when using XamlWriter.Save(object obj) method, so I guess what I need is to write a custom markupextension inheriting from ‘StaticResourceExtension’ that when the ‘ProvideValue(IServiceProvider serviceProvider)’ method is called it simply returns ’string.Format(“{StaticResource {0}}”, this.ResourceKey)’. Is there any way to override default markup extensions with custom ones like this?

Another option would be to control the xaml deserialization(the object graph creation) so I could replace Binding and StaticResources MarkupExtensions for my own implementations.

Accomplishing this would allow me to have complete control over xaml serialization/deserialization process persisting bindings, static resources references, etc when I call the XamlWriter.Save(object obj) method. Currently I am using the tip from this article : http://www.codeproject.com/KB/WPF/xamlwriterandbinding.aspx to allow me persist the bindings, but I still miss the static resources/dynamic resources references.