Saturday, May 1, 2010

Setting data context to list box style in silverlight

I had a requirement to bind the data to a list box defined in a style for a usercontrol.
Here is the code which worked for me after some struggle ... I spent about 2 hours in figuring out this fix with some help over the internet.

Backend data context binding code...
public class DeviceObjectData
{
public string Name { get; set; }
}
Binding
Object.DataContext = new List(){
// list of device objects with name...
}


No comments:

Post a Comment