WPF的ListView与项目的横向排列? [英] WPF ListView with horizontal arrangement of items?

查看:3651
本文介绍了WPF的ListView与项目的横向排列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想展示在ListView项目以类似的方式在列表模式的WinForms ListView控件。也就是说,在项目布局不只是垂直但水平在ListView为好。

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 the ListView as well.

如果该项目被这样的布局,我不介意:

I don't mind if the items are laid out like this:

1 4 7

2 5 8

3 6 9

1 4 7
2 5 8
3 6 9

或者是这样的:

1 2 3

4 5 6

7 8 9

1 2 3
4 5 6
7 8 9

只要它们以最大限度地利用可用的空间的水平和垂直方向psented $ P $

As long as they are presented both vertically and horizontally in order to maximize the use of available space.

这个问题:

<一个href=\"http://stackoverflow.com/questions/359217/how-do-i-make-wpf-listview-items-repeat-horizontally-like-a-horizontal-scrollbar\">http://stackoverflow.com/questions/359217/how-do-i-make-wpf-listview-items-repeat-horizontally-like-a-horizontal-scrollbar

其中仅规定了该项目仅在水平方向。

Which only lays out the items only horizontally.

推荐答案

这听起来像你所寻找的是一个<一个href=\"http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.aspx\">WrapPannel,这将出水平放置的物品,直到有没有更多的空间,然后移动到下一行,像这样的:

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

替换文本

(MSDN)

您也可以使用<一个href=\"http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.uniformgrid.aspx\">UniformGrid,这将奠定项目出的行或列的定数。

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

我们得到一个ListView,ListBox中使用这些其他面板的项目,以人气指数,或​​任何形式的ItemsControl的方式是通过改变<一href=\"http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.itemspanel.aspx\">ItemsPanel属性。通过设置ItemsPanel可以将其从所使用ItemsControls默认的StackPanel变化。随着WrapPanel我们也应设置宽度为这里显示

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.

<ListView>
   <ListView.ItemsPanel>
      <ItemsPanelTemplate>
         <WrapPanel Width="{Binding (FrameworkElement.ActualWidth), 
            RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"
            ItemWidth="{Binding (ListView.View).ItemWidth, 
            RelativeSource={RelativeSource AncestorType=ListView}}"
            MinWidth="{Binding ItemWidth, RelativeSource={RelativeSource Self}}"
            ItemHeight="{Binding (ListView.View).ItemHeight, 
            RelativeSource={RelativeSource AncestorType=ListView}}" />
      </ItemsPanelTemplate>
   </ListView.ItemsPanel>
...
</ListView>

这篇关于WPF的ListView与项目的横向排列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆