wpf grid with dynamic columns

后端 未结 4 1892
轻奢々
轻奢々 2020-12-10 07:03

I have a collection that I wish to bind to a WPF grid.

The problem I\'m facing is that the number of columns is dynamic and is dependent on a collection. Here is a

4条回答
  •  一整个雨季
    2020-12-10 07:22

    Using a grid approach might make things more complicated than they should be. Have you tried changing the template of a listview, or to use the DataGrid instead for this purpose?

    For an example, take a look at this project: http://www.codeproject.com/Articles/25058/ListView-Layout-Manager

    Or this one: http://www.codeproject.com/Articles/16009/A-Much-Easier-to-Use-ListView

    If you go with the Grid, I believe you'll have to add a lot of code behind to manage the amount of columns and rows, their size, the cell content... Whereas a ListView/DataGrid will let you do this dynamically through Templates.

提交回复
热议问题