Silverlight Feeds - All your Silverlight feeds in one place.

Sponsors

Tuesday, July 29, 2008

fast and furios Silverlight Databinding with Gridview and embedded XML Data Resources

by preishuber via Hannes Preishuber on 7/29/2008 6:32:00 PM

 

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.

 image

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

image

Interesting note at the bottom line. It is also possible to load the xaml content.

 Dim myxml  XDocument.Load("/gird1;component/page.xaml")
email it!bookmark it!digg it!

Original Post: fast and furios Silverlight Databinding with Gridview and embedded XML Data Resources

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. Silverlight Feeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on Silverlight Feeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us