I referred this Answer but Its not working. Column still expands to the Row content. Column size is somehow gets updated when cell is re-arranged
Screenshot:
My custom DataGridCellsPanel.ArrangeOverride
:
protected override Size ArrangeOverride(Size arrangeSize)
{
var firstCell = Children[0];
firstCell.SetValue(Panel.HorizontalAlignmentProperty, HorizontalAlignment.Left);
firstCell.Arrange(new Rect(arrangeSize));
for (int i = 1; i < Children.Count; i++)
{
var remainingCell = Children[i];
remainingCell.Arrange(new Rect(0,0,0,0));
}
return arrangeSize;
}
My DataGridRow.Template
:
<Style x:Key="SpanRowStyle" TargetType="DataGridRow">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
<Border>
<DataGridCellsPresenter Foreground="Black">
<DataGridCellsPresenter.ItemsPanel>
<ItemsPanelTemplate>
<controls:DataGridSpannedCellPanel/>
</ItemsPanelTemplate>
</DataGridCellsPresenter.ItemsPanel>
</DataGridCellsPresenter>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Please help.
Found the issue. :)
Setting ColumnWidth to Auto was the culprit. setting it to static values worked fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With