我怎样才能得到一个ListView GridViewColumn填补我的网格中的剩余空间? [英] How can I get a ListView GridViewColumn to fill the remaining space in my grid?
问题描述
我想创建一个ListView,有两列具有固定宽度和第三列,以填补剩余空间。因此,像这样:
I want to create a ListView that has two columns with a fixed width and a third column to fill in the remaining space. So something like this:
<ListView>
<ListView.View>
<GridView>
<GridViewColumn Header="Name" Width="*" />
<GridViewColumn Header="Age" Width="50" />
<GridViewColumn Header="Gender" Width="50" />
</GridView>
</ListView.View>
</ListView>
现在的问题是,我不能找到一个办法让名称
栏,须填写剩余的空间,宽度设置为 *
不起作用。它看起来像有一种方法可以使用<一个做到这一点href="http://social.msdn.microsoft.com/forums/en-US/wpf/thread/3ee5696c-4f26-4e30-8891-0e2f95d69623/">value转换器,但是看起来应该有一个更简单的方法。像一个DataGrid控件,您可以指定列的宽度 *
秒。
The problem is I can't find a way to get the Name
column to fill in the remaining space, as setting the width to *
doesn't work. It looks like there is a way to do this with a value converter, but it seems like there should be a simpler way. Like with a DataGrid control, you can specify the widths of columns with *
s.
推荐答案
这个问题是一个GridViewColumn的列宽一倍,而不是一个GridLength对象,并且在地方处理*没有转换。不知道这是一个监督的WPF团队与否。你可能会认为这shoudl支持。
The issue is the column width of a GridViewColumn is double, rather than a GridLength object, and there is no conversion in place to handle the *. Not sure if this is an oversight by the WPF team or not. You would think it shoudl be supported.
除了转换器,唯一的办法,我已经看到了它做是在这里:的 http://www.ontheblog.net/CMS/Default.aspx?tabid=36&EntryID=37 。
Aside from the converter, the only other way I've seen it done is here: http://www.ontheblog.net/CMS/Default.aspx?tabid=36&EntryID=37.
两者都是不应该需要额外的工作。我已经发现了其他奇怪的事情与ListView和GridView的组合,所以我放弃使用它们。如果我需要一个DataGrid我用的是第三方一个大家许可,如果我需要一个复杂的列表框风格的菜单,我只是用一个模板列表框。
Both are additional work that should not be required. I have found other "weird" things with the ListView and GridView combo so I quit using them. If I need a datagrid I use the 3rd party one we license, if I need a complex ListBox style menu, I just use a templated ListBox.
这篇关于我怎样才能得到一个ListView GridViewColumn填补我的网格中的剩余空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!