I have a
ListView
with three columns. The first two have widths that don't change much (always contain the same number of characters). I can fix the widths of these columns if necessary.
The third column contains notes that can be any length. I would like this column to stretch to fill available space, to display as much of the note as possible. I can do this by giving the column a width of
Auto
, but the header text is always centred and so disappears off the right-hand edge.
The problem is made worse because this
ListView
is the centre (of three) panels made using a
Grid
, and I would like this central panel to be the one that grows and shrinks as the window size is changed.
How can I do this?
What I have tried:
I have tried following various examples but none seems to work.
This is my current code, which doesn't work, but I don't understand why:
<ListView Grid.Row="0" Grid.Column="1" SelectionMode="Single" ItemsSource="{Binding EnquiryJobsFiltered}">
<ListView.View>
<GridView>
<GridViewColumn Header="Enquiry/Job" Width="90" DisplayMemberBinding="{Binding EnquiryJobNumberAsString}"/>
<GridViewColumn Header="Progress" Width="90" DisplayMemberBinding="{Binding Progress}"/>
<GridViewColumn>
<GridViewColumn.HeaderTemplate>
<DataTemplate>
<TextBlock Text="Description" TextAlignment="Left"/>
</DataTemplate>
</GridViewColumn.HeaderTemplate>
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Description}" TextAlignment="Left"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>