tags:

views:

57

answers:

0

I would like to have the columns of the WPF listview:

  1. Grow or shrink in size to occupy all the width available to them, and
  2. Have the content of those columns grow or shrink in size to fit those columns. The content of the columns in my case is text so this means font size will grow or shrink to fit the column.

This code will do almost exactly what I need:

<ScrollViewer  HorizontalContentAlignment="Stretch" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled"> 
   <Viewbox> 
    <ListView>
        <ListView.View>
        <GridView>
            <GridViewColumn Header="col_1" DisplayMemberBinding="{Binding Col_1}" />
            <GridViewColumn Header="col_2" DisplayMemberBinding="{Binding Col_2}"/>
            <GridViewColumn Header="col_3" DisplayMemberBinding="{Binding Col_3}" />
            <GridViewColumn Header="col_4" DisplayMemberBinding="{Binding Col_4}" />
            <GridViewColumn Header="col_5" DisplayMemberBinding="{Binding Col_5}" />
        </GridView>
        </ListView.View>
    </ListView>
    </Viewbox> 
</ScrollViewer>

but, for the fact that when I scroll down the column headers disappear.

Does anybody know how to do that?