W
Wonko the Sane
Hello,
I am having an issue with XamlReader trimming strings with leading or
trailing spaces when reading a ResourceDictionary.
For instance, there may be a string like this:
<sys:String x:Key="strSomeKey"> Notice the space before and after
</sys:String>
I thought that setting XmlReaderSettings.IgnoreWhitespace to false would
prevent this, but it doesn't. See code snippet below. When I check the
ResourceDictionary that gets loaded, the string is "Notice the space before
and after" instead of " Notice the space before and after ".
Thanks,
WtS
<Code>
//Create a new StreamReader.
StreamReader sw = new StreamReader(xamlFile);
//Create an XmlReader
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.CloseInput = true;
readerSettings.IgnoreProcessingInstructions = true;
readerSettings.IgnoreWhitespace = false;
readerSettings.IgnoreComments = true;
readerSettings.ProhibitDtd = true;
XmlReader xmlReader = XmlReader.Create(sw.BaseStream,
readerSettings);
// load English resource dictionary
ResourceDictionary rd = (ResourceDictionary)
XamlReader.Load(xmlReader);
</Code>
I am having an issue with XamlReader trimming strings with leading or
trailing spaces when reading a ResourceDictionary.
For instance, there may be a string like this:
<sys:String x:Key="strSomeKey"> Notice the space before and after
</sys:String>
I thought that setting XmlReaderSettings.IgnoreWhitespace to false would
prevent this, but it doesn't. See code snippet below. When I check the
ResourceDictionary that gets loaded, the string is "Notice the space before
and after" instead of " Notice the space before and after ".
Thanks,
WtS
<Code>
//Create a new StreamReader.
StreamReader sw = new StreamReader(xamlFile);
//Create an XmlReader
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.CloseInput = true;
readerSettings.IgnoreProcessingInstructions = true;
readerSettings.IgnoreWhitespace = false;
readerSettings.IgnoreComments = true;
readerSettings.ProhibitDtd = true;
XmlReader xmlReader = XmlReader.Create(sw.BaseStream,
readerSettings);
// load English resource dictionary
ResourceDictionary rd = (ResourceDictionary)
XamlReader.Load(xmlReader);
</Code>