我想将 ObservableCollection 数据绑定到 WP7 中的 Pivot 控件,以便 ObservableCollection 中的每个对象都成为 PivotItem。这是我使用的代码:
<controls:Pivot x:Name="MainPivot" ItemsSource="{Binding Persons}">
<controls:Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding FullName}"/>
</DataTemplate>
</controls:Pivot.HeaderTemplate>
<controls:Pivot.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17" Width="432">
<TextBlock Text="{Binding FirstName}"/>
<TextBlock Text="{Binding LastName}"/>
<TextBlock Text="{Binding HomeTown}"/>
</StackPanel>
</DataTemplate>
</controls:Pivot.ItemTemplate>
</controls:Pivot>
这有效,并且对于 ObservableCollection 中的 Tre 项,我得到了三个 PivotItems。但是,当所有内容都加载后,DataTemplate 内的绑定将不会更新。只有当我滚动到下一个 PivotItem 时,FirstName、LastName 和 HomeTown 才会加载。
这是为什么?我缺少什么?
Thanks
检查这个讨论:DataBound Pivot 控件未创建第一个 PivotItem https://stackoverflow.com/questions/4114608/databound-pivot-control-is-not-creating-the-first-pivotitem
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)