Windows phone 7 Pivot ItemTemplates Windows Phone 7的MVVM绑定问题

Windows phone 7 Pivot ItemTemplates Windows Phone 7的MVVM绑定问题,windows-phone-7,templates,binding,pivot,itemssource,Windows Phone 7,Templates,Binding,Pivot,Itemssource,我有一个Pivot元素,它有一个header模板,一个itemtemplate和一个listbox,listbox也有一个itemtemplate。标题模板绑定到我通过代码创建的“DOW”列表。这个很好用。每个DOW都有一个entityset TDs,我想将listbox itemtemplate绑定到此源。绑定后,删除项目会更新ui,但添加项目不会更新ui entityset基于以下“具有mvvm的本地数据库”示例: 我研究了几天,没有发现任何有用的东西。我找到了一些解决方案,可以将enti

我有一个Pivot元素,它有一个header模板,一个itemtemplate和一个listbox,listbox也有一个itemtemplate。标题模板绑定到我通过代码创建的“DOW”列表。这个很好用。每个DOW都有一个entityset TDs,我想将listbox itemtemplate绑定到此源。绑定后,删除项目会更新ui,但添加项目不会更新ui

entityset基于以下“具有mvvm的本地数据库”示例:

我研究了几天,没有发现任何有用的东西。我找到了一些解决方案,可以将entityset封装在一个可观察的集合中,但这似乎不起作用。另一个是使用绑定列表,但entitySets不必为WindowsPhone7使用“ToBindingList()”。我在ViewModel中创建了可以绑定到的可观察集合,但是我无法告诉listbox itemtemplate在创建集合时要绑定到哪个集合

有什么想法吗

如果需要,我可以发布更多代码

谢谢

ViewModel中的可观察集合示例

private ObservableCollection<TDItem> _twoDaysAgoItems;
    public ObservableCollection<TDItem> TwoDaysAgoItems
    {
        get { return _twoDaysAgoItems; }
        set
        {

            _twoDaysAgoItems = value;
            NotifyPropertyChanged("TwoDaysAgoItems");
        }
    }

    private ObservableCollection<TDItem> _yesterdayItems;
    public ObservableCollection<TDItem> YesterdayItems
    {
        get { return _yesterdayItems; }
        set
        {
            _yesterdayItems = value;
            NotifyPropertyChanged("YesterdayItems");
        }
    }

    private ObservableCollection<TDItem> _todayItems;
    public ObservableCollection<TDItem> TodayItems
    {
        get { return _todayItems; }
        set
        {

            _todayItems = value;
            NotifyPropertyChanged("TodayItems");
        }
    }
private observedcollection\u two daysagoitems;
公共观察收集两天
{
获取{return\u twoDaysAgoItems;}
设置
{
_twoDaysAgoItems=值;
NotifyPropertyChanged(“TwoDaysAgoItems”);
}
}
私人可观察到的昨天收集项目;
昨天公开可见的收集项目
{
获取{return\u yesterdayItems;}
设置
{
_昨天项目=价值;
NotifyPropertyChanged(“昨天项目”);
}
}
私人可观察到的收集项目;
公众可观察到的今日收集项目
{
获取{return\uTodayItems;}
设置
{
_今天的项目=价值;
NotifyPropertyChanged(“今日项目”);
}
}
实体集

    private EntitySet<TDItem> _tds;
    [Association(Storage = "_ts", OtherKey = "_dowId", ThisKey = "Id")]
    public EntitySet<TDItem> TDs 
    {
        get { return this._tds; 
            }

        set { 
           NotifyPropertyChanging("TDs");
            this._tds.Assign(value);
           NotifyPropertyChanged("TDs");
            }
    }

    public DOW()
    {
        _tds = new EntitySet<TDItem>(
            new Action<TDItem>(this.attach_TD), 
            new Action<TDItem>(this.detach_TD)
            );
    }
private EntitySet\u tds;
[Association(Storage=“\u ts”,OtherKey=“\u dowId”,ThisKey=“Id”)]
公共实体集TDs
{
获取{返回此项。_tds;
}
集合{
通知物业变更(“TDs”);
此项分配(值);
通知财产变更(“TDs”);
}
}
公开道指()
{
_tds=新实体集(
新措施(本附件),
新操作(此.detach_TD)
);
}
支点



Pivot的项目资源未设置。是否缺少其他代码?透视的项目源已通过代码绑定。我最终使用了一个datatemplate选择器,虽然每个模板只有不同的itemsources,但它可以工作。我要看看我还能做什么。
<controls:Pivot x:Name="TDPivotDisplay" SelectedIndex="2" Margin="0,-10,0,0"            Grid.Row="0" Title="TD" Foreground="White" FontWeight="light" VerticalAlignment="Top"   FontSize="29.333" Style="{StaticResource PivotStyle1}" FontFamily="{StaticResource Akzidenz    Grotesk}">
        <controls:Pivot.HeaderTemplate>
            <DataTemplate>
                <StackPanel>
                    <TextBlock x:Name="DOW" Foreground="{Binding Colour}" FontSize="110" FontFamily="{StaticResource Akzidenz Grotesk}" Text="{Binding Header}"/>
                    <TextBlock x:Name = "FullDate" Foreground="{Binding Colour}" FontWeight="light" FontSize="30" FontFamily="{StaticResource Akzidenz Grotesk}"  HorizontalAlignment="center" Text="{Binding Date}"/>
                </StackPanel>
            </DataTemplate>
        </controls:Pivot.HeaderTemplate>

        <controls:Pivot.ItemTemplate>
            <DataTemplate>
                <Grid Height="421">
                    <ListBox ItemsSource = "{Binding TDs}" ItemTemplate = "{StaticResource ListboxItemTemp}"  x:Name ="TDLists"  Margin="12, 0, 12, 0" Width="440"/>
                </Grid>
                </DataTemplate>
        </controls:Pivot.ItemTemplate>

    </controls:Pivot>