I am currently writing a Silverlight 2.0 course. I always try to focus on the problem and reduce the code overhead. For my Module “Databinding with Silverlight 2.0” I try to include the data as raw xml. For that purpose I include a northwind.xml file as data source into the project to focus on datagrid details. The most important part is, to set the build action to content, which ends up in including the xml file into the xap package.
Then you can load the xml directly by xdocument.load. I had problems when xml is not valif or have exoctic encoding ( windows-1252). Rest is a little bit LINQ to create collection of northwinddata objects.
Dim myxml = XDocument.Load("northwind.xml") Dim xmlquery1 = From x In myxml.Descendants("row") _ Select New northwinddata With _
{.customerid = x.@CustomerID, _ .companyname = x.@CompanyName}
dataGrid1.ItemsSource = xmlquery1
Finally the result
Interesting note at the bottom line. It is also possible to load the xaml content.
Dim myxml XDocument.Load("/gird1;component/page.xaml")