GridView 中的附加列
我使用列表来填充 WPF GridView
作为其 ItemsSource
。这是我使用的 xaml 标记:
<ListView.View>
<GridView>
<GridViewColumn Header="Subject" DisplayMemberBinding="{Binding Path=Subject}" />
<GridViewColumn Header="Start" DisplayMemberBinding="{Binding Path=StartingDate}" />
<GridViewColumn Header="End" DisplayMemberBinding="{Binding Path=EndingDate}" />
<GridViewColumn Header="Commissioner" DisplayMemberBinding="{Binding Path=Commissioner}" />
<GridViewColumn Header="Description" DisplayMemberBinding="{Binding Path=QuickNotes}" />
</GridView>
</ListView.View>
令人惊讶的是(至少对我来说),我得到了一个额外的(空)列,如下所示。我错过了什么重要的一点?
I use a List to populate a WPF GridView
as its ItemsSource
. This is the xaml markup I use:
<ListView.View>
<GridView>
<GridViewColumn Header="Subject" DisplayMemberBinding="{Binding Path=Subject}" />
<GridViewColumn Header="Start" DisplayMemberBinding="{Binding Path=StartingDate}" />
<GridViewColumn Header="End" DisplayMemberBinding="{Binding Path=EndingDate}" />
<GridViewColumn Header="Commissioner" DisplayMemberBinding="{Binding Path=Commissioner}" />
<GridViewColumn Header="Description" DisplayMemberBinding="{Binding Path=QuickNotes}" />
</GridView>
</ListView.View>
Surprisingly (at least for me), I get an additional (empty) column as shown below. What important point am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种替代方法是使用 DataGrid 而不是 ListView。然后,您可以将其中一列的宽度设置为 *,这将导致它占用所有剩余空间。遗憾的是,您无法在 GridView 列上设置 * 的宽度。
One alternative is to use a DataGrid instead of the ListView. Then you can set one of the Columns to have a Width of * which will cause it to take up all remaining space. Sadly you can't set a width of * on GridView columns.
它不是“实际”列,它更像是最后一列旁边的空白区域。
It's not an "actual" column, it's more like empty space next to the last column.