This is my XAML:
<ListView ItemsSource="{B开发者_如何学运维inding 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..)
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.
精彩评论