WindowsCommunityToolkit
WindowsCommunityToolkit copied to clipboard
DataGrid: TextWrapping fixing issue when resizing
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>
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.
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
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
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
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
Looking for an update