none
DataGrid控件能否做出多行表头效果? RRS feed

答案

  •         <Style TargetType="{x:Type dg:DataGridColumnHeader}">
                <Setter Property="VerticalContentAlignment" Value="Center" />
                <Setter Property="Foreground" Value="Black" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type dg:DataGridColumnHeader}">
                            <Grid>
                                <Border Name="MainBorder" BorderThickness="2"  Margin="0,0,0,0" BorderBrush="#9AD2F9" Background="#C4E7FF">
                                    <Grid>
                                        <StackPanel Orientation="Horizontal">
                                            <CheckBox Name="_chHead" Click="_chHead_Click"  Margin="0,2,2,0"   />
                                          
                                            <ContentPresenter Margin="1" HorizontalAlignment="Left" VerticalAlignment="Center" Content="{TemplateBinding Content}"
                                                           ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}"/>

                                        </StackPanel>
                                    </Grid>
                                </Border>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
    2010年4月21日 13:20

全部回复

  • 你的意思是把默认的列表头换为行表头吗?如果是请参见:

    http://bbs.silverlightchina.net/viewthread.php?tid=920&extra=page%3D1

    2010年4月21日 9:13
  •         <Style TargetType="{x:Type dg:DataGridColumnHeader}">
                <Setter Property="VerticalContentAlignment" Value="Center" />
                <Setter Property="Foreground" Value="Black" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type dg:DataGridColumnHeader}">
                            <Grid>
                                <Border Name="MainBorder" BorderThickness="2"  Margin="0,0,0,0" BorderBrush="#9AD2F9" Background="#C4E7FF">
                                    <Grid>
                                        <StackPanel Orientation="Horizontal">
                                            <CheckBox Name="_chHead" Click="_chHead_Click"  Margin="0,2,2,0"   />
                                          
                                            <ContentPresenter Margin="1" HorizontalAlignment="Left" VerticalAlignment="Center" Content="{TemplateBinding Content}"
                                                           ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}"/>

                                        </StackPanel>
                                    </Grid>
                                </Border>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
    2010年4月21日 13:20