views:

3134

answers:

4

For a Silverlight 2 webapp. I added a combobox. I have an IEnumerable as Itemsource to populate the combobox. Works fine.

But I would like to add an extra item ("please select a....") to the combobox, anyone an idea how this can be done using the Silverlight 2 combobox.

Any more info about using a template for the ComboxboxItems is welcome as well.

+1  A: 
RobZ
A: 

After returning a List<> from an asynchnorus call to a WCF service I use the following syntax to add an item to the results before binding to the combo box. In my scenario if you try to add the item to the list after binding a read only error is thrown.

E.Result.Items.Insert(0,new object{ param1 = "", Param2 = ""});

David Casey
A: 

Just add that in Xaml page and make it selected to True....

Taran
A: 

u can use this code if u r using WCF.

SilverlightApplication1.ServiceReference1.Region item=new SilverlightApplication1.ServiceReference1.Region (); item.RegionID = 0; item.RegionDescription = "-Select Region-"; e.Result.Insert(0, item);

drControl.ItemsSource = e.Result;////////.Result;
drControl.SelectedIndex = 0;

Sitab Bhandari