none
DataGrid 调整那个Tempate可以怎么把表头纵向放置 RRS feed

答案

  • 我想可以通过Rotate来实现这个功能。我粗略的写了一个。你可以试试:

        <Grid>
            <DataGrid x:Name="UserGrid" CanUserAddRows="False">
                <DataGrid.ColumnHeaderStyle>
                    <Style TargetType="{x:Type DataGridColumnHeader}">
                        <Setter Property="LayoutTransform">
                            <Setter.Value>
                                <TransformGroup>
                                    <RotateTransform Angle="90"/>
                                </TransformGroup>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </DataGrid.ColumnHeaderStyle>
                <DataGrid.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90"/>
                    </TransformGroup>
                </DataGrid.LayoutTransform>
                <DataGrid.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Setter Property="RenderTransform">
                            <Setter.Value>
                                <RotateTransform Angle="90"/>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </DataGrid.CellStyle>
            </DataGrid>
        </Grid>

    这里有一个例子:http://stackoverflow.com/questions/4132829/wpf-horizontal-datagrid

    希望我的回复能够帮到你。


    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.

    2014年3月3日 2:58
    版主

全部回复

  • 我想可以通过Rotate来实现这个功能。我粗略的写了一个。你可以试试:

        <Grid>
            <DataGrid x:Name="UserGrid" CanUserAddRows="False">
                <DataGrid.ColumnHeaderStyle>
                    <Style TargetType="{x:Type DataGridColumnHeader}">
                        <Setter Property="LayoutTransform">
                            <Setter.Value>
                                <TransformGroup>
                                    <RotateTransform Angle="90"/>
                                </TransformGroup>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </DataGrid.ColumnHeaderStyle>
                <DataGrid.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90"/>
                    </TransformGroup>
                </DataGrid.LayoutTransform>
                <DataGrid.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Setter Property="RenderTransform">
                            <Setter.Value>
                                <RotateTransform Angle="90"/>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </DataGrid.CellStyle>
            </DataGrid>
        </Grid>

    这里有一个例子:http://stackoverflow.com/questions/4132829/wpf-horizontal-datagrid

    希望我的回复能够帮到你。


    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.

    2014年3月3日 2:58
    版主
  • 太感谢你了
    2014年3月3日 4:27