1.XAML
<controls:Pivot x:Name="myPivot" ItemsSource="{Binding LiveProgramGuideList}" SelectedIndex="{Binding DayIndex}" DataContext="{Binding}"> <controls:Pivot.HeaderTemplate> <DataTemplate> <TextBlock Text="{Binding DayName}"/> </DataTemplate> </controls:Pivot.HeaderTemplate>
<controls:Pivot.ItemTemplate> <DataTemplate> <controls:PivotItem > <ListBox x:Name="ListEPG" Margin="0,-40,-12,0" Height="580" ItemsSource="{Binding EPGList}" Width="432" SelectedIndex="{Binding TodayListIndex}" > <ListBox.ItemTemplate> <DataTemplate> <StackPanel x:Name="stackPanel" Margin="0,0,0,5" Width="432" Height="80" Orientation="Horizontal" Background="Black" >
<TextBlock Name="tbTitle" Text="{Binding contentName, Mode=OneTime}" / >
...
</StackPanel>
</DataTemplate> </ListBox.ItemTemplate> </ListBox> </controls:PivotItem> </DataTemplate> </controls:Pivot.ItemTemplate>
</controls:Pivot>
2.数据源为WM中的数据
问题:
1).数据绑定后,不能访问ListBox--ListEPG
2).本例数据集为四个,我想对第2个pivotitem中的Listbox做页面上的处理
后台:
Listbox lb=(myPivot.items[2] as pivotitem ).content as ListBox
结果:myPivot.items[2]是VM中的数据类型,myPivot.items[2] as pivotitem 为空
谢谢大侠们!