在ListView垂直网格线 [英] Vertical gridlines in a ListView

查看:433
本文介绍了在ListView垂直网格线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经得到了我使用的是作为一个GridView一个WPF的ListView。有什么办法,我可以在那里得到的垂直网格线?

I've got a WPF ListView that I'm using as a GridView. Is there any way I can get vertical gridlines in there?

ListView控件具有了minHeight指定的,所以我想网格线一路到网格的底部,所以它会填充空白区域。

The ListView has a MinHeight specified, so I'd like the GridLine to go all the way to the bottom of the grid, so it'll fill the empty space.

这似乎是一个相当棘手的问题。是否能够解决?

This seems to be a rather tricky problem. Is is possible to solve?

推荐答案

这是我要做的事。

<ListView Name="lvwDivided" 
          Grid.IsSharedSizeScope="True"
          ItemsSource="{Binding Path=myList}" >
    <ListView.ItemTemplate>
        <DataTemplate>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="3*" SharedSizeGroup="col0"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="1*" SharedSizeGroup="col2"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0"
                           Text="{Binding Path=Name}"/>
                <Border Grid.Column="1" 
                        BorderBrush="DarkGray" 
                        BorderThickness="0,0,1,0" />
                <TextBlock Grid.Column="2"
                           Text="{Binding Path=DateModified}"/>
            </Grid>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

SharedSizeGroup Grid.IsSharedSizeScope 性能的关键是做的这样。

The SharedSizeGroup and Grid.IsSharedSizeScope properties are key to this way of doing it.

这会照顾衬里的事情了,但它不会延伸到的地方有没有数据。如果你想要的功能列表视图可能不是最好的选择。

This will take care of lining things up, but it won't extend into areas where there is no data. A ListView might not be the best option if you want that functionality.

这篇关于在ListView垂直网格线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆