using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
namespace MergeGridTest
{
/// <summary>
/// test1window.xaml 的交互逻辑
/// </summary>
public partial class test1window : Window
{
DrawingVisual dv = new DrawingVisual();
public test1window()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var Doctors = new List<Doctor>()
{
new Doctor(){Name="Zhang",Score=15,Address="Chengdu",Dept="Neike"},
new Doctor(){Name="Zhang",Score=18,Address="Chengdu",Dept="Neike"},
new Doctor(){Name="Zhang",Score=17,Address="Chengdu",Dept="Neike"},
new Doctor(){Name="Liu",Score=15,Address="Chengdu",Dept="Thke" },
new Doctor(){Name="Liu",Score=18,Address="MianYang",Dept="Thke"},
new Doctor(){Name="Liu",Score=17,Address="MianYang",Dept="Thke"}
};
TestGrid.ItemsSource = Doctors;
}
}
class Doctor
{
public string Name { get; set; }
public int Score { get; set; }
public string Address { get; set; }
public string Dept { get; set; }
}
}
个字符
(https://note.youdao.com/yws/public/resource/ae451287f619092cc8b0485de1ddc297/xmlnote/AC1E5BD45A1C46A190271C395E0BBAA2/23392)
如图所示,我不想显示最后一行(最后一条红线)下的线在这个数据网格,但其他水平线显示正常,怎么做?
数据网格的行设置是针对所有行的,所以我不能只设置最后一行的行视觉样式。
1条答案
按热度按时间bxjv4tth1#
您可以通过以下步骤来实现这一点:
1.将
DataGrid
的GridLinesVisibility
属性设置为None
。(隐藏所有水平和垂直网格线)2.将
DataGridTextColumn
替换为DataGridTemplateColumn
,并将Border
Package 的单元格内容放入DataGridTemplateColumn
的CellTemplate
中3.将
Border
的BorderThickness
设置为"0,1,0,0"
,将Margin
设置为"-1"
,将BorderBrush
设置为您喜欢的任何颜色下面是一个可能的基于原始代码的示例代码段:
字符串