Psych971


Hi, this is something that should be extremely simple but isn't -- or maybe I'm just missing something.

I want to make it so that all my GridView cells fill up ALL available horizontal space, and not leave any awkward whitespace on the right. Additionally I want to ensure that the columns size themselves to fit their contents. If anyone's been able to accomplish this I'd enormously appreciate any tips.

Thanks!
Rich



Re: Extend the last column in a GridView

Drew Marsh


To make sure columns fit their content, specify the Width="Auto". To get one column to fill all the remaining space in the Grid use Width="*". For more details on Grid sizing, please check out this section of the SDK that discusses GridUnitTypes.

HTH,
Drew





Re: Extend the last column in a GridView

Psych971

I know how to resize a grid, but I'm talking about in the context of a ListView/GridView. If I try the following I get an error stating that "*" cannot be converted to a Length:

<ListView x:Name="PART_MyGrid" IsSynchronizedWithCurrentItem="True" Width="Auto" Height="Auto" >

<ListView.View>

<GridView >

<GridViewColumn Header="Column1" DisplayMemberBinding="{Binding Path=Column1}" Width="Auto" />

<GridViewColumn Header="Column2" DisplayMemberBinding="{Binding Path=Column2}" Width="*" />

</GridView>

</ListView.View>

</ListView>

I want Column1 to display the full contents, and Column2 to extend all the way to the right edge of the grid.






Re: Extend the last column in a GridView

Drew Marsh

Ahh, my mistake. I missed the "View" part of GridView.

Check out this thread. Despite the original poster giving up because the implementation provided by LeeD was not a 100% solution for him, the theory is still sound. All that needs to happen to support resizing of the list view is that the value converter needs to become a multi-value converter where the first parameter should be the ListView instance itself and the second its ActualWidth property.

HTH,
Drew





Re: Extend the last column in a GridView

Psych971

Thanks Drew Smile

Guess I'll have to settle with that workaround for now. I just hope they have better support for this type of thing in v2.

Thanks again,

Rich