WPF ListView with horizontal arrangement of items?

前端 未结 5 1160
粉色の甜心
粉色の甜心 2020-11-28 04:44

I want to lay out items in a ListView in a similar manner to the WinForms ListView in List mode. That is, where items are laid out not just vertically but horizontally in th

5条回答
  •  醉酒成梦
    2020-11-28 05:36

    It sounds like what you are looking for is a WrapPannel, which will lay the items out horizontally until there is no more room, and then move to the next line, like this:

    (MSDN)
    alt text http://i.msdn.microsoft.com/Cc295081.b1c415fb-9a32-4a18-aa0b-308fca994ac9(en-us,Expression.10).png

    You also could use a UniformGrid, which will lay the items out in a set number of rows or columns.

    The way we get the items to arange using these other panels in a ListView, ListBox, or any form of ItemsControl is by changing the ItemsPanel property. By setting the ItemsPanel you can change it from the default StackPanel that is used by ItemsControls. With the WrapPanel we also should set the widths as shown here.

    
       
          
             
          
       
    ...
    
    

提交回复
热议问题