繁体   English   中英

数据透视表wp7中的DataTemplate

[英]DataTemplate in pivotItems wp7

我想在wp7中创建一个数据透视页:

 <Grid x:Name="LayoutRoot" Background="Transparent">
    <!--Pivot Control-->
    <controls:Pivot Title="MY APPLICATION">
        <!--Pivot item one-->
        <controls:PivotItem Header="item1">
            <Grid/>
        </controls:PivotItem>

        <!--Pivot item two-->
        <controls:PivotItem Header="item2">
            <Grid/>
        </controls:PivotItem>
    </controls:Pivot>
</Grid>

我需要将pivoItems与我的List<Article>自动绑定,并且将List<Article>类定义如下:

  public class Article
{
    private string _logoUrl;
    public string LogoUrl
    {
        get { return _logoUrl; }
        set { _logoUrl = value; }
    }
    private string _title;
    public string Title
    {
        get { return _title; }
        set { _title = value; }
    }
    private string _descrption;
    public string Descrption
    {
        get { return _descrption; }
        set { _descrption = value; }
    }
}

如何使用Datatemplate将每个PivotItem与每个Article绑定(我需要每个Article的标题都显示在PivotItem的标题中以及Webbrowser中的描述中,因为它是HTML)

最好的祝福

首先,要为每篇文章创建一个PivotItem ,只需使用ItemsSource属性:

<controls:Pivot Title="MY APPLICATION" ItemsSource="{Binding Path=TheListOfArticles}">

要更改标题,请覆盖HeaderTemplate

<controls:Pivot ItemsSource="{Binding Path=TheListOfArticles}" Title="MY APPLICATION">
    <controls:Pivot.HeaderTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Path=Title}" />
        </DataTemplate>
    </controls:Pivot.HeaderTemplate>
</controls:Pivot>

同样,重写ItemTemplate定义每个PivotItem显示方式:

<controls:Pivot.ItemTemplate>
    <DataTemplate>
        <!-- whatever -->
    </DataTemplate>
</controls:Pivot.ItemTemplate>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM