Which Table/Grid Control in WPF?

馋奶兔 提交于 2019-12-04 06:05:53
N_A

There are several ways to accomplish what you're trying to do here. If performance is not an issue then I would ignore virtualization and try the DockPanel The drawback here is that you would have to add the items in order rather than adding them by row.

Another option would be to use two stack panels (one in each direction). This addresses the adding issue, but requires the use of more panels.

Both of the previous two options would require individual items to have their height/width set.

A final option (depending on how large your grid is), would be to use a Grid with fixed sized rows and columns with items that span rows (using the rowspan property). The drawback of this method is that I don't know of any good way to create this control in xaml for unspecified numbers of rows/columns so you would have to create it in code to get the needed number of rows/columns.

If you have performance issues you could try using the VirtualizingStackPanel. If this still doesn't meet your performance requirements then you will need to subclass the VirtualizingPanel and tailor it to meet your specific needs.

See here for more information on Panel performance.

I suggest trying the two StackPanel method first, then the VirtualizingStackPanel method and finally, if that doesn't work, then try the VirtualizingPanel

Padding is easily accomplished by setting the Margin property on each subcontrol.

For scrolling use the ScrollViewer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!