1

I want to Display a collection of shapes in a specific way. So, I have a collection of shapes ViewModels, and I want to display it like this :

1) If my collection contains only one shape :

enter image description here

2) If my collection contains 3 shapes :

enter image description here

3) if my collection contains more than 3 shapes : (automatically creates a new Row with 3 columns)

enter image description here

You may say to me "Use UniformGrids", but the problem is that the size of columns is the same ! and I want to have columns with different size ! (depending on the size of elements inside it)

1 Answer 1

2

I'm pretty sure what you need is to use a WrapPanel.

MSDN Article : http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel%28v=vs.100%29.aspx

Tutorial on how to use it ( wpftutorial ) : http://wpftutorial.net/WrapPanel.html

Edit : Follow this interesting link too : Specifying number of items per row using a WrapPanel

2
  • 3
    It is customary for users to provide some code example in their answer, rather than just providing one or more links. Please take a look at the Provide context for links page of the StackOverflow help centre for more information.
    – Sheridan
    Oct 9, 2013 at 13:15
  • 1
    I added another link that has some example, I think there is no need now for examples since the SO link already shows perfect code example ( that I don't have enough knowledge to reproduce ). Thanks for the tip, next answer I'll provide will have some examples. Oct 9, 2013 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.