开发者

Display a variable-sized collection of TextBlocks/ComboBoxes in Silverlight 3

I have a list of textual descriptions, each of which a user must score on a scale of 1-5. The number of textual descriptions is variable, so I can't just define a static Grid in XAML.

The following image shows approximately what I'm 开发者_StackOverflowafter:

Display a variable-sized collection of TextBlocks/ComboBoxes in Silverlight 3

In ASP.NET, I could bind my list of text items to a Repeater control. For each row, the text would be displayed in a Label, and next to it would be a DropDownList that contains a static list of items. Is there a similar control available in Silverlight?

Should I be using one of these?

  • DataGrid
  • ListBox
  • Custom control derived from ItemsControl
  • (Other)


I solved this by using an ItemsControl, and within the ItemTemplate I placed the TextBlock and ComboBox controls.

The only wrinkle for me was that the ComboBox depended on a separate DataContext, so I had to resort to using the DataContextProxy described in this article

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜