>As someone coming into silverlight programming from the ASP.NET world (and many earlier worlds), I'm absolutely astounded as to how completely broken and not-ready for BETA the combobox in Silverlight is when trying to populate it from any data source.
The procedure is the same as for any ItemsControl:
Set the ItemsSource to an IEnumerable.
Set the DisplayMemberPath to the text to be displayed
Set the SelectedItem to the relevant object in the IEnumerable.
>I've literally spent days trying to get a combobox in a datagrid to populate the items from a RIA domaindatasource or any other method of getting data from my entity framework (using domaindatasource) objects.
>
>I've read so many contradictory/fragmented/error filled/incomplete blogs and other articles on the web that I could just hurl.
>
>I've yet to get it to populate (then I have to tackle setting selected item which appears more broken).
>
>This is supposed to be silverlight 4. IMHO it hasn't reached an alpha release for a 1.0 version yet.
>
>If anyone has a clear cut, COMPLETE and ACCURATE example of doing this I'd love to see it.
Binding to a DomainDataSource in code:
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
DomainDataSource dds = new DomainDataSource();
dds.DomainContext = new CustomerDomainContext();
dds.QueryName = "GetCustomers";
dds.Load();
cbox.ItemsSource = dds.Data;
cbox.DisplayMemberPath = "CustName";
}
}