Resizing a datagrid column using CanUserResize = "True" does not work in WPF

I used CanUserResize = "True" for the datagrid column, but I cannot resize when I hover over the column heading.

<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> 
+5
source share
1 answer

Since I changed the datagrid column header template, so resizing won't work fine

so add this code, the size will work.

 <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"/> 
+6
source

Source: https://habr.com/ru/post/1208428/


All Articles