如何创建带有重复标题的列表视图,其中绑定数据继续到下一列

时间:2017-12-15 13:04:05

标签: c# wpf listview

我正在尝试使用列表视图创建以下方案。我想要3列重复三次。

    A   B   C   A   B   C   A   B   C
    a1  b1  c1  a2  b2  c2  a3  b3  c3
    a4  b4  c4  a5  b5  c5  a6  b6  c6
    a7  b7  c7  a8  b8  c8  a9  b9  c9

其中A =运行,B = KP,C =时间

    <ListView 
 VirtualizingStackPanel.IsVirtualizing="True"  ItemContainerStyle="{StaticResource KPListViewItemStyle}"  
                          SelectionMode="Extended"   x:Name="lstKP"   MouseDoubleClick="lstKP_MouseDoubleClick" 
                          Grid.ColumnSpan=" 2"  Grid.Row=" 1" Grid.RowSpan="5" >
                    <ListView.View>                            
                        <GridView>                                
                            <GridView.Columns>
                                <GridViewColumn >
                                    <UniformGrid Columns="3">
                                        <GridViewColumnHeader >
                                            <TextBlock Text="Run"></TextBlock>                                                
                                        </GridViewColumnHeader>
                                        <GridViewColumnHeader >
                                            <TextBlock Text="KP"></TextBlock>
                                        </GridViewColumnHeader>
                                        <GridViewColumnHeader >
                                            <TextBlock Text="Time"></TextBlock>
                                        </GridViewColumnHeader>
                                    </UniformGrid>                                        
                                </GridViewColumn>                                   
                            </GridView.Columns>
                        </GridView>
                    </ListView.View>
                    <ListView.ItemsPanel>
                        <ItemsPanelTemplate>
                            <UniformGrid Columns="3" />
                        </ItemsPanelTemplate>
                    </ListView.ItemsPanel>
                    <ListBox.ItemTemplate>

                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" >
                                <TextBlock Text="{Binding runTime, StringFormat=N2}"    Margin=" 20,0,0,0"/>
                                <TextBlock Text="{Binding KPString}"  Margin=" 20,0,0,0"/>
                                <TextBlock Text="{Binding timeFormatted}"  Margin=" 20,0,0,0"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListView

我可以获取布局数据,但不能列出列标题。

感谢您的帮助

0 个答案:

没有答案