Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to generate variable gridviewcolumns based on size of list in code behind

$
0
0

I have a listview with a gridview and gridview columns in it. How would I modify the gridview columns so that I can genereate a variable number of column in code behind so that depending on a list provided, the size of the list will determine the number of columns for the gridview?

Here is the static code for generating a fixed number of columns.

<ListView x:Name="ModelerListView"><ListView.View><GridView><GridViewColumn Header="Date"
                      DisplayMemberBinding="{Binding Path=Date}"
                      Width="100"/><GridViewColumn Header="Coulmn1"  Width="100" ><GridViewColumn.CellTemplate><DataTemplate><TextBox Text="{Binding Column1}" Width="80" /></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn><GridViewColumn Header="Coulmn2"  Width="100" ><GridViewColumn.CellTemplate><DataTemplate><TextBox Text="{Binding Column2}"  Width="80"/></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn><GridViewColumn Header="Coulmn3"  Width="100" ><GridViewColumn.CellTemplate><DataTemplate><TextBox Text="{Binding Column3}" Width="80" /></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn></GridView></ListView.View></ListView>


chuckdawit


Viewing all articles
Browse latest Browse all 18858

Trending Articles