WindowsCommunityToolkit icon indicating copy to clipboard operation
WindowsCommunityToolkit copied to clipboard

DataGrid: TextWrapping fixing issue when resizing

Open Scnck opened this issue 6 years ago • 6 comments

What is the proper method of applying text wrapping so that when resizing a column to auto adjust the row height?

https://stackoverflow.com/questions/54584552/uwp-datagrid-textwrapping-rowheight-issues

<controls:DataGridTextColumn Width="300" IsReadOnly="True" Header="Description" Binding="{Binding Description}">
	<controls:DataGridTextColumn.ElementStyle>
		<Style TargetType="TextBlock">
			<Setter Property="TextWrapping" Value="Wrap" />
		</Style>
	</controls:DataGridTextColumn.ElementStyle>
</controls:DataGridTextColumn>

Scnck avatar Feb 08 '19 13:02 Scnck

I don't have a good workaround in mind for this. It looks like a bug in ...\WindowsCommunityToolkit\Microsoft.Toolkit.Uwp.UI.Controls.DataGrid\DataGrid\DataGridCellsPresenter.cs's protected override Size MeasureOverride(Size availableSize).

    if (double.IsNaN(this.OwningGrid.RowHeight))
    {
        // No explicit height values were set so we can autosize
        autoSizeHeight = true;
        measureHeight = double.PositiveInfinity;
        this.DesiredHeight = 0;   <-- missing line in the current code
    }

Adding that one line of code addresses the issue I believe. I am not 100% sure there are no bad side-effects yet. The problem is that the line this.DesiredHeight = Math.Max(this.DesiredHeight, cell.DesiredSize.Height); starts with the original & old DesiredHeight instead of starting with 0.

RBrid avatar Oct 11 '19 20:10 RBrid

Thanks Scnck for patiently waiting while the team is still investigating the issue.

@anawishnoff @RBrid can we please have an update on this issue? Thanks

ghost avatar Apr 08 '21 18:04 ghost

Thanks Scnck for patiently waiting while the team is still investigating the issue.

@anawishnoff @RBrid can we please have an update on this issue? Thanks

ghost avatar May 09 '21 00:05 ghost

Thanks Scnck for patiently waiting while the team is still investigating the issue.

@anawishnoff @RBrid can we please have an update on this issue? Thanks

ghost avatar Jun 08 '21 06:06 ghost

Thanks Scnck for patiently waiting while the team is still investigating the issue.

@anawishnoff @RBrid can we please have an update on this issue? Thanks

ghost avatar Jul 08 '21 12:07 ghost

Looking for an update

SharpDevSa avatar Mar 05 '24 12:03 SharpDevSa