ResourceDictionaryWriterCreateXamlWriterSettings Method |
Namespace: Ab2d.Utility.ReaderSvg
protected virtual BaseXamlWriterSettings CreateXamlWriterSettings()
The CreateXamlWriterSettings method by default creates an instance of WpfXamlWriterSettings that is used for GetXaml method.
The method can be overriden to create an instance of SilverlightXamlWriterSettings instead of WpfXamlWriterSettings. The derived method can also set some properties, for example NumberFormatString.
Note that in order to work correctly the following properties cannot be changed in derived class:
NamedObjects, RootObject, XamlNamespace, StartComment, WriteElementNames and WriteRootObjectResouceKey.
Other setting such as NumberFormatString and others can be changed to any other values.
The following sample creates a new SilverlightResourceDictionaryWriter that derive from ResourceDictionaryWriter. It creates an instance of SilverlightXamlWriterSettings instead of WpfXamlWriterSettings and also sets a custom NumberFormatString.
public class SilverlightResourceDictionaryWriter : Ab2d.Utility.ReaderSvg.ResourceDictionaryWriter { protected override BaseXamlWriterSettings CreateXamlWriterSettings() { SilverlightXamlWriterSettings newSilverlightXamlWriterSettings; newSilverlightXamlWriterSettings = new SilverlightXamlWriterSettings(); // format decimal numbers to show only one decimal newSilverlightXamlWriterSettings.NumberFormatString = "0.#"; return newSilverlightXamlWriterSettings; } }