AB4D Forum

Full Version: ResourceDictionaryWritter code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am currently using the trial version of the ReaderSvg and I'm interested in using the ResourceDictionaryWritter utility. I would like to know if its possible to set the UseColorNames property to false and edit the format of the resource dictionary xaml with the purchase of ReaderSvg. Or is it still going to be the same with the purchase?
To change the value of UseColorNames property and other properties in XamlWriterSettings (WpfXamlWriterSettings or SilverlightXamlWriterSettings) you first need to create your own class that derives from ResourceDictionaryWriter. Than you will be able to override the CreateXamlWriterSettings method. This method returns the BaseXamlWriterSettings that is used to create the XAML.

The original method is:

protected virtual BaseXamlWriterSettings CreateXamlWriterSettings()
{
WpfXamlWriterSettings newXamlWriterSettings;

newXamlWriterSettings = new WpfXamlWriterSettings();

return newXamlWriterSettings;
}

So if you would like to change the UseColorNames you can use the following:

protected override BaseXamlWriterSettings CreateXamlWriterSettings()
{
var newXamlWriterSettings = base.CreateXamlWriterSettings();
newXamlWriterSettings.UseColorNames = false;

return newXamlWriterSettings;
}


If you would like to create xaml for Silverlight you can use (sample from the help file for CreateXamlWriterSettings method):

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;
}
}


I hope this answers your question.