Share WrapPanel Free Space

I am using WrapPanel in WPF to display images. When resizing the form, these images try to take the maximum free space, but when the image can almost fill the space, there is a relatively large gap at the end of the WrapPanel. I would like to do this to divide this space between images before a new one fills this gap (for example, what Windows 7 Explorer does when displaying image icons).

+6
source share
1 answer

The BalancedWrapPanel search code for WPF is in this article.

Or you can calculate Margin for Images as ((Width of WrapPanel) - (summ Width of Images)) / (Images count) and set the Image property of WrapPanel Resources to the Margin property.

+3
source

Source: https://habr.com/ru/post/889478/


All Articles