我怎样才能得到一个ListView GridViewColumn填补我的网格中的剩余空间?我的、网格、剩余、空间

由网友(怪老头.)分享简介:我想创建一个ListView,有两列具有固定宽度和第三列,以填补剩余空间。因此,像这样:I want to create a ListView that has two columns with a fixed width and a third column to fill in the remaining spa...

我想创建一个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>

现在的问题是,我不能找到一个办法让名称栏,须填写剩余的空间,宽度设置为 * 不起作用。它看起来像有一种方法可以使用​​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.

阅读全文

相关推荐

最新文章