简体   繁体   English

来自相同源的数据显示在数据透视表头中,而不显示在数据透视表项模板中

[英]data from the same source is displayed in the pivot header but not in the pivot item template

I am binding data to a pivot element in UWP. 我将数据绑定到UWP中的枢轴元素。 The data is displayed in the header template but the same header data when i try to display in the item template inside, it is not being shown. 数据显示在标题模板中,但当我尝试显示在项目模板内部时,标题数据相同,但未显示。 Why is this happening?? 为什么会这样? Also, the same data is being displayed in the item template outside the grid view. 同样,相同的数据正在网格视图外部的项目模板中显示。

  <Pivot x:Name="Pivot1" ItemsSource="{Binding Store_Product_x}" SelectionChanged="Pivot1_SelectionChanged">
                <Pivot.HeaderTemplate>
                    <DataTemplate >
                        <TextBlock Text="{Binding Course_Header}"/>
                    </DataTemplate>
                </Pivot.HeaderTemplate>
                <Pivot.ItemTemplate>
                    <DataTemplate>
                        <!--<TextBlock Text="{Binding Course_Header}"/>-->
                        <GridView ItemsSource="{Binding Store_Product_x}">
                            <GridView.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Course_Header}"/>
                                </DataTemplate>
                            </GridView.ItemTemplate>
                        </GridView>
                    </DataTemplate>
                </Pivot.ItemTemplate>
            </Pivot>

For Pivot , one PivotHeader corresponds one PivotItem . 对于Pivot ,一个PivotHeader对应一个PivotItem And in your code one PivotItem also corresponds one GridView . 在您的代码中,一个PivotItem也对应一个GridView If the above code can run and meet your requirements, the GridView will only have one item under every PivotItem and value is same with PivotHeader , in that case why did we need the GridView ? 如果上面的代码可以运行并满足您的要求,则GridView在每个PivotItem下将只有一个项目,并且PivotHeader值相同,在这种情况下,为什么我们需要GridView

For example, the itemsource Store_Product_x have two records and you bind to the Pivot . 例如,itemsource Store_Product_x有两个记录,并且您绑定到Pivot So the Pivot will have two items with headers shown. 因此, Pivot将显示两个带有标题的项目。 The first item is bind record 1 of Store_Product_x , and the second item is bind record 2 of Store_Product_x . 第一项是Store_Product_x绑定记录1,第二项是Store_Product_x绑定记录2。 At the same time, under every item you have a GridView . 同时,在每个项目下都有一个GridView The first GridView has same source with first item which is record 1, how it bind Store_Product_x which contains record 1? 第一个GridView与第一个项目(记录1)具有相同的来源,它如何绑定包含记录1的Store_Product_x

Please clear that the PivotItem to GridViewItems in your code is 1 to many relationship. 请清除代码中从PivotItemGridViewItems一对多关系。 Your above code is obviously wrong. 您上面的代码显然是错误的。 Please reference the nested bind I mentioned in your previous thread. 请参考我在上一个线程中提到的嵌套绑定。

If you cannot think out a right structure to meet your requirements you can consider change the control. 如果您无法想出合适的结构来满足您的要求,则可以考虑更改控件。

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

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