1

我有自定义样式的 DataGrid,我在重新调整列大小时遇到​​问题,因为它仅在光标完全位于两列之间时才有效

这是设置 DataGridColumnHeader 的样式部分

    <Style TargetType="{x:Type DataGridColumnHeader}">
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="Foreground" Value="White"/>
    <Setter Property="FontFamily" Value="Segoue UI"/>
    <Setter Property="FontSize" Value="14"/>
    <Setter Property="Height" Value="40"/>

    <Setter Property="Template">

        <Setter.Value>
            <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
                <Grid>
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="#6b6b6b">
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>

                    <Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
4

2 回答 2

2

像这样增加拇指的宽度:

 <Thumb x:Name="PART_RightHeaderGripper" Width="100" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}"/>
于 2015-01-28T15:54:44.223 回答
0

You could change it in run time too. here is the example

grd.Columns[1].Width =new DataGridLength(60); 

mention the index

于 2015-01-30T14:47:42.430 回答