DataBound Pivot控件未创建第一个PivotItem [英] DataBound Pivot control is not creating the first PivotItem

查看:55
本文介绍了DataBound Pivot控件未创建第一个PivotItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows Phone 7页面中,我具有以下控件:

In a Windows Phone 7 page I have the following control:

<controls:Pivot x:Name="Pivoter" Title="{Binding Name}" 
      TitleTemplate="{StaticResource PivotTitleTemplate}" 
      HeaderTemplate="{StaticResource PivotHeaderTemplate}"
      ItemsSource="{Binding Items}"
      ItemTemplate="{StaticResource DisplayItemDataTemplate}">
</controls:Pivot >

使用此DataTemplate:

with this DataTemplate:

<DataTemplate x:Key="DisplayItemDataTemplate">    
    <Image Grid.Column="0" Stretch="Uniform"
        Source="{Binding LargeImage, Converter={StaticResource UriBitmapConverter}}"/>
    <StackPanel Grid.Column="1" Orientation="Vertical">
        <HyperlinkButton NavigateUri="{Binding Uri}" Content="{Binding Uri}"/>
    </StackPanel>    
</DataTemplate>

ItemsSourceObservableCollection.显示页面时,它会创建所有PivotItems,但是除非我向前滚动并返回至第一项目,否则不会创建第一项.它在滚动列表中有一个条目,但没有PivotItem控件.

The ItemsSource is an ObservableCollection. When the page is displayed it creates all of the PivotItems but the first item does not get created unless I scroll forward and back to it. It has an entry in the scroll list but no PivotItem control.

如果我在Pivot Control的LoadingPivotItem事件中设置了一个断点,则在第一次显示枢轴时不会调用该断点,而只有在我滚动并返回到第一项时才被击中.

If I put a break point in the Pivot Control's LoadingPivotItem event it is not called when the pivot is first displayed but again only gets hit when I scroll away and back to the first item.

有人看到Pivot控件有类似行为并且可以解决吗?还是我做错了什么?

Has anybody seen similar behavior for the Pivot control and have a work around? Or am I doing something incorrectly?

推荐答案

我遇到了同样的问题.

I ran into this same problem.

似乎应该在构造函数中设置数据透视表的DataContext.如前所述,我在Page_Loaded事件中设置了DataContext,第一个数据透视项不会触发Loading事件.通过较早地绑定我的DataContext,事件开始触发.

It appears the DataContext for the pivot should be set in the constructor. I was setting my DataContext in the Page_Loaded event and the first pivot item would not fire the Loading event, as described. By simply binding my DataContext earlier, the event started firing.

我相信这是框架中的错误,但我还没有做足够的工作来确认它.

I believe it's a bug in the framework, but I haven't done enough to confirm it.

这篇关于DataBound Pivot控件未创建第一个PivotItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆