1

我正在创建一个 RSS 阅读器,并想PivotItem为用户拥有的 RSS 创建 s。

我知道我会将项目数传递到 PivotView 中,这样我就可以在创建时创建项目数。

有谁知道我将如何以编程方式处理这个问题?

4

1 回答 1

3

最好的方法是使用MVVM模式。

您可以为订阅创建一个视图模型类并将它们添加到 ObservableCollection。然后,您只需要将 Pivots ItemsSource 属性绑定到集合:

        <controls:Pivot ItemsSource="{Binding Path=Subscriptions}">
            <controls:Pivot.ItemTemplate>
                <DataTemplate>
                    <controls:PivotItem Header="{Binding Path=DisplayName}">
                        <Listbox ItemsSource="{Binding Path=Items}">
                            ...
                            ...
                        </ListBox>
                    </controls:PivotItem>
                </DataTemplate>
            </controls:Pivot.ItemTemplate>
        </controls:Pivot>
于 2011-11-15T10:42:09.127 回答