Why is XAML Width = "Auto" not working for me?

I started serving some poorly written XAML. I am relatively new to XAML.

One thing I need: grid columns should automatically adjust width for text content.

The MSDN documentation on GridViewColumn.Width says - set the Auto parameter to Auto-sizing. However, although the code is read as follows, the width of the columns remains the same regardless of the content text.

<ListView.View>
<GridView>
<GridViewColumn x:Name="lstColName" Width="200">Name</GridViewColumn>
<GridViewColumn x:Name="lstColPath" Width="Auto">Path</GridViewColumn>
</GridView>
</ListView.View>
+3
source share
3 answers

GridViewrecalculates the sizes of the contents of the columns only when changing the template or the internal collection of columns, therefore Width="Auto"it only works when loading GridView.

.

+2

, .

    <ListView>
        <ListView.View>
            <GridView>
                <GridViewColumn x:Name="Spoons" Width="Auto">

                </GridViewColumn>

            </GridView>
        </ListView.View>
    </ListView>
0

All Articles