WPF ListView with GridViewColumn and DataTemplate

You need to define the data template as CellTemplate for your column: <ListView x:Name=”lbDatabases” Height=”138″ Width=”498″ Canvas.Left=”44″ Canvas.Top=”146″ > <ListView.View > <GridView > <GridViewColumn Header=”Databases” Width=”498″> <GridViewColumn.CellTemplate> <DataTemplate> <CheckBox IsChecked=”{Binding IsActive}” Checked=”AnyChange” Unchecked=”AnyChange” Style=”{x:Null}” Content=”{Binding DbName}” Width=”{Binding CheckWidth}” /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView>

How to autosize and right-align GridViewColumn data in WPF?

To make each of the columns autosize you can set Width=”Auto” on the GridViewColumn. To right-align the text in the ID column you can create a cell template using a TextBlock and set the TextAlignment. Then set the ListViewItem.HorizontalContentAlignment (using a style with a setter on the ListViewItem) to make the cell template fill the … Read more