sbaeumlisberger / VirtualizingWrapPanel

Implementation of a comprehensive VirtualisingWrapPanel for WPF
MIT License
242 stars 33 forks source link

If ItemSize not set, ItemSize should be max size of displayed items #7

Closed DrkWzrd closed 4 years ago

DrkWzrd commented 4 years ago

In VirtualizingWrapPanel,UpdateChildSize this fragment of code

childSize = InternalChildren[0].DesiredSize; (line 114)

makes fixed bigger size children not showing entirely.

It should be

var castChildren= InternalChildren.Cast<UIElement>(); var maxWidth = castChildren.Max(uielement=> uielement.DesiredSize.Width); var maxHeight = castChildren.Max(uielement=> uielement.DesiredSize.Height); childSize = new Size(maxWidth, maxHeight);

sbaeumlisberger commented 4 years ago

Hi,

as described in the API documentation all items (childs) must have the same size. If this can not be guaranteed by the items itself, you can set the ItemSize property.

The case that the items have different sizes is unfortunately not supported. The problem is that only the desired size of the realized items is known. Therefore, it is not possible to reliably calculate the maximum items size.