ResourceDictionaryWritter code
#2
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.
Andrej Benedik
  


Messages In This Thread
ResourceDictionaryWritter code - by itspria - 01-28-2014, 12:27 AM
RE: ResourceDictionaryWritter code - by abenedik - 02-02-2014, 08:53 PM

Forum Jump:


Users browsing this thread:
1 Guest(s)