Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resizing datagrid column with CanUserResize="True" is not working in WPF

I have used the CanUserResize="True" for the datagrid column but i can't able to resize while hover on the column header.

<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>
like image 204
Gowthaman Avatar asked Dec 05 '14 12:12

Gowthaman


1 Answers

Since i had changed the Template of the datagrid column header so the resizing will not working properly

so add this code the resizing 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"/>
like image 84
Gowthaman Avatar answered Sep 24 '22 00:09

Gowthaman