开发者

Additional column in GridView

I u开发者_StackOverflowse 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?

Additional column in 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.

<DataGrid>
    <DataGrid.Columns>
        <DataGridTextColumn Header="Subject" />
        <DataGridTextColumn Header="Start" />
        <DataGridTextColumn Header="End" />
        <DataGridTextColumn Header="Commissioner" />
        <DataGridTextColumn Header="Description" Width="*" />
    </DataGrid.Columns>
</DataGrid>


It's not an "actual" column, it's more like empty space next to the last column.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜