Reputation: 147
I have a ListView (GridView) bound to a collection. For aesthetic reason, I want an empty column at the beginning. If I do
<ListView.View>
<GridView>
<GridViewColumn Width="100" />
<GridViewColumn Header="Col 1" DisplayMemberBinding="{Binding P1}" />
<GridViewColumn Header="Col 2" DisplayMemberBinding="{Binding P2}" />
<GridViewColumn Header="Col 3" DisplayMemberBinding="{Binding P3}" />
</GridView>
</ListView.View>
I get the .ToString() of the ItemSource in the first column. I just want an empty column, and I do not want to bind to an empty string property. Any idea?
I just hope it is not too obvious...
Upvotes: 1
Views: 1792
Reputation: 14860
Even better than a DataTemplate
, use {x:Null}
as a binding.
<GridViewColumn Header="Empty Column" DisplayMemberBinding="{Binding Source={x:Null}}" />
Defining a DataTemplate
is verbose and causes lagging when scrolling through a ListView with many items.
Upvotes: 0
Reputation: 2954
Or just don't specify anything...
<GridViewColumn Header="Col 3" Width="500" />
Upvotes: -1
Reputation: 102793
Maybe use an empty CellTemplate
?
<GridViewColumn Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate />
</GridViewColumn.CellTemplate>
</GridViewColumn>
Upvotes: 8