views:

1112

answers:

2

I haven't been able to successfully bind some test data to a SketchFlow ComboBox. I added a sample data source and created a collection with some basic string values. There are a number of tutorials on how to bind to a ListBox in SketchFlow and that works fine, just not finding anything for a ComboBox.

A: 

It seems to work as I expected, so perhaps I'm not understanding your issue correctly, but I'll give it a shot! I created a sample DataSource with a couple of strings in it, added a ComboBox to the layout root and then just dragged the Collection from the DataSource and dropped it on the ComboBox.

Keep in mind that if you drag the DataSource itself, you'll only be setting the DataContext property of the ComboBox and that's not enough to get your items to display. You also need the ItemsSource bound to the Collection of the DataSource and an ItemTemplate or a DisplayMemberPath to tell the ComboBox how to display your items.

Additionally, if you use the drag and drop method of binding, it will use the ItemTemplate approach for you, which may or may not be what you want as it will generally create a StackPanel and display all fields from the row in your Collection per item in the ComboBox. You can remove the ItemTemplate and set DisplayMemberPath to whichever field you wish to have displayed from your data source's collection.

Shane Brandt
I was doing what you described. I tried again on a new page (originally was on a page I created with a few different states that I was switching between). My new page just has a ComboBox control and a simple DataSource with just a few strings. When I run the project, I receive a runtime error "Unhandled Error in Silverlight Application AG_E_PARSER_BAD_TYPE". I just tried using DisplayMemberPath instead of the ItemTemplate but receive the same error. I appreciate the help, SketchFlow looks really promising.
Clay
I just tried with a brand new project and the steps you described work fine now. There is apparently something else causing problems within my original project. Thanks again!
Clay
+3  A: 

One thing that caught me out a few times is that you need to have your data in "list mode" before you drag it on to the control (combo box or list box).

Hugh