none
gridview column autofit

    Question

  • I have a gridview. The column headers can change during runtime. How can I get the columns to autofit themselves after the headers change?
    Bill
    Wednesday, September 02, 2009 9:12 PM

Answers

All replies

  • Bill,

    Try http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/7a07dcf6-f2da-44af-a9ec-1c05d063ae08
    Whatever triggers the change in the headers, must also reset the width to double.NaN.

    Hope this helps.
    noorbakhsh
    Wednesday, September 02, 2009 9:19 PM
  • Hi Bill,

    I think you can try the solution Rbakhsh provided. By the way, if you just want to stretch the content of the item container, you can try the following code snippet:
    <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                    </Style>
    </ListView.ItemContainerStyle>

    Hope this helps.
    Thanks.


    Jim Zhou -MSFT
    Tuesday, September 08, 2009 9:34 AM