如何在wpf

时间:2017-08-22 06:29:27

标签: wpf telerik

我正在研究WPf并使用telerik Control。现在我想知道如何在WPF中将列名添加到分层RadGridView中? 见图: capture image

请提供全面的帮助。

1 个答案:

答案 0 :(得分:0)

请试试这个,应该真的很有帮助。

    <UserControl.Resources>
    <Style TargetType="{x:Type telerik:GridViewHeaderRow}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type telerik:GridViewHeaderRow}">
                    <telerik:SelectiveScrollingGrid>
                        <telerik:SelectiveScrollingGrid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </telerik:SelectiveScrollingGrid.ColumnDefinitions>
                        <Border x:Name="PART_GridViewHeaderRowBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="4" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                        </Border>
                        <telerik:DataCellsPresenter x:Name="PART_DataCellsPresenter" Grid.Column="3" IsTabStop="False">
                        </telerik:DataCellsPresenter>
                        <Border x:Name="PART_IndicatorPresenter" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,0,1,1" telerik:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" Visibility="{TemplateBinding RowIndicatorVisibility}" Width="25">

                        </Border>
                        <telerik:IndentPresenter x:Name="PART_IndentPresenter" Grid.Column="1" IsTabStop="False" IndentLevel="{TemplateBinding IndentLevel}" MinHeight="{TemplateBinding MinHeight}" telerik:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical">

                        </telerik:IndentPresenter>
                        <Border x:Name="PART_HierarchyIndentPresenter" Grid.Column="2" telerik:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" Width="40">
                            <Border.Visibility>
                                <Binding Path="HasHierarchy" RelativeSource="{RelativeSource TemplatedParent}">
                                    <Binding.Converter>
                                        <telerik:BooleanToVisibilityConverter/>
                                    </Binding.Converter>
                                </Binding>
                            </Border.Visibility>
                            <TextBlock Text="Parts" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FF767676" FontSize="12" FontWeight="Bold" FontFamily="Segoe UI"></TextBlock>

                        </Border>
                    </telerik:SelectiveScrollingGrid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Background" Value="{DynamicResource Office2007Silver}">
        </Setter>
        <Setter Property="MinHeight" Value="27"/>
        <Setter Property="BorderBrush" Value="#FF848484"/>
        <Setter Property="BorderThickness" Value="1,0,0,1"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
    </Style>
</UserControl.Resources>