网格中列表视图项后的水平线

时间:2016-04-23 01:31:21

标签: c# .net wpf

如何在网格中的每个列表视图项之后插入水平线?

<Grid>
    <ListView Margin="10" Name="Users">
        <ListView.View>
            <GridView>
                <GridViewColumn Header="Name" Width="300">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock TextWrapping="Wrap" TextTrimming="WordEllipsis" Height="32" Text="{Binding Name}" />                           
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
                <GridViewColumn Header="Age" Width="200">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock TextWrapping="Wrap" TextTrimming="WordEllipsis" Height="32" Text="{Binding Age}" />
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
            </GridView>
        </ListView.View>
    </ListView>
</Grid>

我尝试在DataTemplate

之后定义Border
<DataTemplate>
  <Border Margin="5" BorderThickness="1" BorderBrush="SteelBlue">

但是只在每个数据模板项周围添加了边框。如何在每行后插入水平分隔符?

1 个答案:

答案 0 :(得分:1)

我认为您应该能够通过ItemContainerStyle

设置行样式

https://stackoverflow.com/a/4474474/424129

您希望将BorderThickness="0,0,0,1"设置为仅包含底部边框。