How to make WPF wrappanel child items to stretch?

Use a UniformGrid rather than a WrapPanel . Just set the number of columns you want with the Columns property, and it should give you the desired result.

Up vote 1 down vote favorite 1 share g+ share fb share tw.

I'd like to create an ItemsControl where child items are placed like a WrapPanel, but child Items should take as much space as it can. So that when the window size gets larger or smaller, the child items should stretch according to a certain width:height ratio. When the child items get added or removed from the ItemsControl's ItemsSource, the WrapPanel should place linebreaks among items appropriately to keep child item's width:height ratio.

Below is what I have so far. Is it possible to do this in Xaml? Or should I create a custom control for this?

Thanks in advance! Wpf xaml custom-controls itemscontrol wrappanel link|improve this question edited Nov 16 '11 at 0:24 asked Nov 4 '11 at 4:48Daniel748415 91% accept rate.

Does unlimited vertical orientation UniformGrid serve your purpose... social.msdn.microsoft.com/Forums/en-US/w... – AngelWPF Nov 4 '11 at 6:08 I think it's somewhat different from what I need, but thanks! – Daniel Nov 4 '11 at 6:34 Wrap and stack panels intentionally take up as little space as possible. As far as I've seen you can't override that behavior, so you must use a different type of grouping control.

– Merlyn Morgan-Graham Nov 16 '11 at 1:18.

Use a UniformGrid rather than a WrapPanel. Just set the number of columns you want with the Columns property, and it should give you the desired result.

Have you tried the HorizontalContentAlignment="Stretch" property in the itemscontrol.

Yes, but it doesn't work. Thanks for suggesting – Daniel Nov 5 '11 at 10:07 Can you post the whole code in DataTemplate. – Tan Nov 7 '11 at 16:14 I've posted the whole code in DataTemplate, thanks – Daniel Nov 16 '11 at 0:35 as I can see HorizontalContentAlignment="Stretch" would work.

– Tan Dec 5 '11 at 16:07.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions