我使用过CanUserResize =" True"对于datagrid列,但我可以在将鼠标悬停在列标题上时调整大小。
<DataGrid x:Name="ScenarioExecutables" AutoGenerateColumns="False" CanUserAddRows="False" RowHeaderWidth="0" Margin="10" FontSize="14"
Grid.Row="1" CanUserResizeColumns="True">
<DataGrid.Columns>
<DataGridTextColumn Header="Scenario" Width="1*" IsReadOnly="True" CanUserResize="True">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="Description" Width="2*" CanUserResize="True"/>
</DataGrid.Columns>
</DataGrid>
答案 0 :(得分:7)
由于我更改了datagrid列标题的模板,因此调整大小将无法正常工作
所以添加此代码,调整大小将起作用..
<Thumb x:Name="PART_RightHeaderGripper" Grid.Column="1"
HorizontalAlignment="Right"
Width="2" BorderThickness="1"
BorderBrush="{Binding VerticalGridLinesBrush, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"
Cursor="SizeWE"/>