Reputation: 19864
This is my XAML:
<ListView ItemsSource="{Binding Items}">
<ListView.View>
<GridView>
<GridViewColumn Header="Property1" DisplayMemberBinding="{Binding Property1}" />
<GridViewColumn Header="Property2" DisplayMemberBinding="{Binding Property2}" />
</GridView>
</ListView.View>
</ListView>
I want these 2 columns to take up the width of ListView in 1:1 ratio.
How can I achieve this?
Edit: I found this suggestion on MS Connect. This would perfectly solve my problem. However it is closed as postponed (for 2.5 years now..)
Upvotes: 1
Views: 2390
Reputation: 185290
What comes to mind is using internal Grids
in the templates which each have a ColumnDefinition
with the same SharedSizeGroup
, the GridView
should then have Grid.IsSharedSizeScope="True"
and the columns of the grid view should themselves be unresizable (if that is possible), cannot test that right now so it's a bit sketchy.
Another method would be to bind both Widths
of the GridViewColumns
to the width of the ListView
and then use a custom converter to get an appropriate fraction of that back.
Upvotes: 1