Marginal Layout panel like Windows 7 Explorer ListView
In Windows Explorer in Windows 7, items in ListView has flexible margin. So all of icons fit in region of ListView.
How can i make a panel which implemented like this? WrapPanel
is most approaching 开发者_如何学Cthat, it's not flawless - a WrapPanel
doesn't fit items to it's boundaries through adjusting margin.
Try using WrapPanel as your ListView's item panel and disable the horizontal scrollbar:
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
...
</ListView>
ItemTemplate specifies how each item should be rendered. It has no effect on how items are laid out. ItemsPanel, by contrast, does specify the layout.
Also, you may want all items to be displayed the same size. You can find out how to do that from this article:
http://joshsmithonwpf.wordpress.com/2008/09/06/synchronizing-the-width-of-elements-in-an-itemscontrol/
精彩评论