问个简单问题:WPF的Listview行与行,列与列之间怎样加线条?就像winform 2.0的DataGridView那样?

时间:2021-08-09 14:45:03
默认时就像一个没有加边框效果的Excel文档打印出来时效果,我想加边框。请问怎么做,谢谢。

6 个解决方案

#1


顶~

#2


listView的GridLines属性改成true

#3


顶!并推荐一个好地方!http://hi.baidu.com/happyf101
希望大家支持一下!

#4


这个问题不好弄。我的办法是重写GridViewColume.CellTemplate,为每个Cell加上一个框。

#5


<ScrollContentPresenter Name="PART_ScrollContentPresenter"
                KeyboardNavigation.DirectionalNavigation="Local">
                                <ScrollContentPresenter.Content>
                                    <Grid>
                                        <ItemsControl Margin="3,0,0,0" ItemsSource="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}">
                                            <ItemsControl.ItemTemplate>
                                                <DataTemplate>
                                                    <Border Width="{Binding Path=ActualWidth}" BorderThickness="0,0,1,0" BorderBrush="{DynamicResource verticalLineColor}" />
                                                </DataTemplate>
                                            </ItemsControl.ItemTemplate>
                                            <ItemsControl.ItemsPanel>
                                                <ItemsPanelTemplate>
                                                    <StackPanel Orientation="Horizontal" />
                                                </ItemsPanelTemplate>
                                            </ItemsControl.ItemsPanel>
                                        </ItemsControl>
                                        <ContentControl Content="{TemplateBinding Content}" />
                                    </Grid>
                                </ScrollContentPresenter.Content>
                            </ScrollContentPresenter>

#6


到了WPF 3.5,算是用WPF Toolkit里的DataGrid解决了问题:-)

#1


顶~

#2


listView的GridLines属性改成true

#3


顶!并推荐一个好地方!http://hi.baidu.com/happyf101
希望大家支持一下!

#4


这个问题不好弄。我的办法是重写GridViewColume.CellTemplate,为每个Cell加上一个框。

#5


<ScrollContentPresenter Name="PART_ScrollContentPresenter"
                KeyboardNavigation.DirectionalNavigation="Local">
                                <ScrollContentPresenter.Content>
                                    <Grid>
                                        <ItemsControl Margin="3,0,0,0" ItemsSource="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}">
                                            <ItemsControl.ItemTemplate>
                                                <DataTemplate>
                                                    <Border Width="{Binding Path=ActualWidth}" BorderThickness="0,0,1,0" BorderBrush="{DynamicResource verticalLineColor}" />
                                                </DataTemplate>
                                            </ItemsControl.ItemTemplate>
                                            <ItemsControl.ItemsPanel>
                                                <ItemsPanelTemplate>
                                                    <StackPanel Orientation="Horizontal" />
                                                </ItemsPanelTemplate>
                                            </ItemsControl.ItemsPanel>
                                        </ItemsControl>
                                        <ContentControl Content="{TemplateBinding Content}" />
                                    </Grid>
                                </ScrollContentPresenter.Content>
                            </ScrollContentPresenter>

#6


到了WPF 3.5,算是用WPF Toolkit里的DataGrid解决了问题:-)