none
datagrid 如何实现2级header RRS feed

答案

  • 你好 Rogerguo,

    你可以参考这个帖子里的答案:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/1e414159-70f6-4be3-9be5-56e4f3278366/wpf-multicolumn-super-header

    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="2*"/>
                        </Grid.RowDefinitions>
                        <Grid Grid.Row="0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="{Binding ElementName=datagrid1, Path=RowHeaderWidth}" />
                                <ColumnDefinition Width="{Binding ElementName=Column1, Path=ActualWidth}" />
                                <ColumnDefinition Width="{Binding ElementName=Column2, Path=ActualWidth}" />
                                <ColumnDefinition Width="{Binding ElementName=Column3, Path=ActualWidth}" />
                                <ColumnDefinition Width="{Binding ElementName=Column4, Path=ActualWidth}" />
                            </Grid.ColumnDefinitions>
                            <Border Grid.Column="1" Grid.ColumnSpan="3" BorderBrush="Black" HorizontalAlignment="Stretch" BorderThickness="2">
                                <Label>Super Header!!</Label>
                            </Border>
                        </Grid>
                        <tools:DataGrid AutoGenerateColumns="False"
                                    Name="datagrid1" Grid.Row="1" RowHeaderWidth="10">
                            <tools:DataGrid.Columns>
                                <tools:DataGridTextColumn Header="column 1" Width="100" x:Name="Column1" />
                                <tools:DataGridTextColumn Header="column 2" Width="80" x:Name="Column2"/>
                                <tools:DataGridTextColumn Header="column 3" Width="80" x:Name="Column3"/>
                                <tools:DataGridTextColumn Header="column 4" Width="*" x:Name="Column4"/>
                            </tools:DataGrid.Columns>
                        </tools:DataGrid>
                    </Grid>

    这里用的是http://wpftoolkit.codeplex.com/



    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2015年1月8日 10:14
    版主