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; }
}
}
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MergeGridTest"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2" x:Class="MergeGridTest.test1window"
mc:Ignorable="d"
Title="test1window" Height="450" Width="800" Loaded="Window_Loaded">
<Grid>
<DataGrid Background="LightBlue" x:Name="TestGrid" AutoGenerateColumns="False" Margin="50" IsReadOnly="True"
CanUserAddRows="False" ItemsSource="{Binding}"
RowHeight="30" HorizontalGridLinesBrush="#FFCB0202" VerticalGridLinesBrush="{x:Null}" VerticalContentAlignment="Center">
<DataGrid.Columns>
<DataGridTextColumn Header="Address" Binding="{Binding Name}" Width="*"/>
<DataGridTextColumn Header="Score" Binding="{Binding Score}" Width="*"/>
<DataGridTextColumn Header="Address" Binding="{Binding Address}" Width="*"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>
如图所示,我不想在此数据网格中的线下显示最后一行(最后一条红线),但是其他水平线正常显示,该怎么做?
数据网格的行设置适用于所有行,因此我不能仅将行的视觉样式设置为最后一行。