加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows-phone-7 – 在WP7上将PivotItems数据绑定到ObservableCo

发布时间:2020-12-14 01:52:02 所属栏目:Windows 来源:网络整理
导读:我想将一个ObservableCollection数据绑定到WP7中的Pivot contronl,以便我的ObservableCollection中的每个对象都变成一个PivotItem.这是我使用的代码: controls:Pivot x:Name="MainPivot" ItemsSource="{Binding Persons}" controls:Pivot.HeaderTemplate Da
我想将一个ObservableCollection数据绑定到WP7中的Pivot contronl,以便我的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,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.

这是为什么?我错过了什么?

谢谢

解决方法

看看这个讨论:
DataBound Pivot control is not creating the first PivotItem

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读