Search code examples
c#wpfitemscontrolflowlayout

FlowLayout ItemsControl in WPF


I need a really simple ItemsControl actually. I want all the items in the collection to be put left to right and when it's not enough space to fit the next element, it should be put on the next line.

So basically like FlowLayout in Java Swing, or the normal Icon folder view in Windows.

I can't believe this is not built in, but for some reason I can't find it.


Solution

  • Have a look at these:

    http://msdn.microsoft.com/en-us/library/ms750564%28v=vs.85%29.aspx

    Specifically the WrapPanel

    Edit:

    The ItemsControl control has a ItemsPanel Property which you canset to use a WrapPanel:

    http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.itemspanel.aspx