开发者

How to evenly space out GridViewColumns in GridView?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜