我正在写一个Silverlight应用程序。我想要一个垂直显示行的列表框。然后,对于每一行,该行上应该有一个标题列,然后是一个面板的水平列表。我已经弄清楚了布局。我的问题是数据绑定。
列表框正在绑定到集合。该集合中的每个项都将是列表框中的一行。集合中的每个项都有一个集合,该集合将绑定到每个ListBox行内的ItemsControl ItemsSource。
[标题][x][y][z]
[标题][x2][y2][z2]
[标题][x3][y3][z3]
我需要使用的绑定语法是什么?
<ListBox Name="listRuleSteps" Height="150" Loaded="ListBox_Loaded" ScrollViewer.VerticalScrollBarVisibility="Auto">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Vertical" Height="50">
<dataInput:Label Content="{Binding StepID}"></dataInput:Label>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Vertical">
<ItemsControl ItemsSource="{Binding SelectedItem.RuleEngineParts, ElementName=listRuleSteps}" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<controlToolkit:WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<controlToolkit:WrapPanel Width="100">
<dataInput:Label Content="Text1"></dataInput:Label>
</controlToolkit:WrapPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我认为问题出在这条线上。我显然不想使用SelectedItem,但我不确定绑定ItemsSource的内容。
<ItemsControl ItemsSource="{Binding SelectedItem.RuleEngineParts, ElementName=listRuleSteps}" >
如果你认为我这样做是完全错误的,请让我知道。我对Silverlight真的很陌生。