Sunday, October 03, 2010

Different Ways to Bind Data Grid in Silverlight

In the previous article I described the basics of Data Binding in Silverlight. In this article I will demonstrate How to Bind Data grid with different data sources like:
Binding with Static Collection/List
Binding with XML
Binding with Database via WCF Services
Binding with Database via WCF RIA Services
To setup an example let’s create a new Silverlight project is VS 2010 called “DataBinding”. See “How to create Silverlight application in VS 2010” for more information. Let’s create add a new Class file called “Item.cs” with Item Class as following:
namespace DataBinding
{
   public class Item
   {
       public string ItemNumber { get; set;}
       public string ItemDescription { get; set; }
       public int Quantity { get; set; }
       public Item()
       {
       }
       public Item(string ItemNumber, string ItemDescription, int Quantity)
       {
           this.ItemNumber= ItemNumber;
           this.ItemDescription = ItemDescription;
           this.Quantity = Quantity;
       }
   }
}
Read more: Beyond relational