8,735
社区成员
发帖
与我相关
我的任务
分享
<Window x:Class="Tabcontrol1.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window2" Height="530" Width="547" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit"
xmlns:dd="clr-namespace:System.Data;assembly=System.Data">
<Window.Resources>
<!--定义一个列标题样式-->
<Style x:Key="dgHeaderStyle" TargetType="my:DataGridColumnHeader">
<Setter Property="Background" Value="Black" />
<Setter Property="Foreground" Value="White" />
<Setter Property="BorderBrush" Value="Red" />
<Setter Property="BorderThickness" Value="1" />
</Style>
<Style x:Key="RowStyle" TargetType="my:DataGridRow" >
<Setter Property="Background" Value="Yellow" />
<Setter Property="Foreground" Value="Red" />
</Style>
<dd:DataTable x:Key="LineX"/>
</Window.Resources>
<Grid Background="Black">
<my:DataGrid AutoGenerateColumns="False" Margin="23,42,206,174" Name="dataGrid1" ItemsSource="{Binding Source={StaticResource LineX}}"
Background="Black"
ColumnHeaderStyle="{StaticResource dgHeaderStyle}"
RowStyle="{StaticResource RowStyle}"
>
<my:DataGrid.Columns>
<my:DataGridTextColumn Header="AAA" Foreground="White" />
<my:DataGridTextColumn Foreground="White" Header="BBB" />
</my:DataGrid.Columns>
</my:DataGrid>
</Grid>
</Window>