To solve the second part of your question:
Try to get the xml in this way:
I am not sure about your folder structure, but here my XML is inside the Resources Folder.
Stream stream = Application.GetResourceStream(new Uri("Resources/XMLFile1.xml", UriKind.RelativeOrAbsolute)).Stream;
StreamReader reader = new StreamReader(stream);
XDocument xDoc = XDocument.Parse(reader.ReadToEnd());
Also try not to use "var" types. For ex:
XDocument.Load()
function will always return XDocument type only.
Update:
Assembly can also be used, an Example:
here WpfApplication2 is the namespace, Resources is the Folder name.
Assembly assembly = Assembly.GetExecutingAssembly();
Stream stream = assembly.GetManifestResourceStream("WpfApplication2.Resources.XMLFile1.xml");
StreamReader reader = new StreamReader(stream);
XDocument xDoc = XDocument.Parse(reader.ReadToEnd());
But the catch is, your XML should be an "Embedded Resource" instead of simple Resource. Otherwise the stream will be null.
For more reading, you can check out this link:
http://www.silverlightexamples.net/post/How-to-Get-Files-From-Resources-in-Silverlight-20.aspx[
^]
Hope it helped.