一个比较漂亮的DataGrid样式表

body { font-family:宋体,MS Sans Serif; font-size:9pt; word-break:break-all; }
p  { font-family:宋体,MS Sans Serif; font-size:9pt; }
table { font-family:宋体,MS Sans Serif; font-size:9pt; }
tr  { font-family:宋体,MS Sans Serif; font-size:9pt; }
td
{
 font-size: 9pt;
 overflow: hidden;
 font-family: 宋体,MS Sans Serif;
}
input { font-family:宋体,MS Sans Serif; font-size:9pt; }

.InputField { font-family:宋体,MS Sans Serif;font-size:9pt; }

a:link  {   color: #003399;text-decoration: none;}
a:active{   color: #003399;text-decoration: none;}
a:hover {   color: #003399;text-decoration: none;}
a:visited {   color: #003399;text-decoration: none;}

.Banner { font-family:宋体, MS Sans Serif;font-size:9pt;font-weight:bold;
   color:#ffffff;filter:Shadow(color=#000000,directsion=135) }
   
.Title { font-family:宋体, MS Sans Serif;font-size:9pt;
   color:#ffffff; }

.Categoriestitle { font-family:宋体, MS Sans Serif;font-size:9pt;font-weight:bold;
   color:#000000; }
.Categoriestext { font-family:宋体, MS Sans Serif;font-size:9pt;
   color:#000000; }
   
.Copyrighttext { font-family:宋体, MS Sans Serif;font-size:9pt;font-weight:normal;
   color:#ffffff; }
   

.Menu:link  { color:#000000;text-decoration:none; }
.Menu:active { color:#000000;text-decoration:none; }
.Menu:hover  { color:#000000;text-decoration:none; }
.Menu:visited { color:#000000;text-decoration:none; }

.ErrTitle{ font-family:宋体, MS Sans Serif;font-size:18pt;font-weight:bold;
   color:#000000; }
   
.Subject{ font-family:宋体, MS Sans Serif;font-size:16pt;font-weight:bold;
   color:#003399; }
   
.SubjectDesc { font-family:宋体, MS Sans Serif;font-size:9pt;color:#003399;font-weight:normal }
  
.ContextTitle{ font-family:宋体, MS Sans Serif;font-size:12pt;font-weight:bold;
   color:#000000; }
   
   
.NewButton  { width:16px;height:15px;background-image:url(../images/banner/new.gif) }
.EditButton  { width:16px;height:15px;background-image:url(../images/banner/edit.gif) }
.DelButton  { width:16px;height:15px;background-image:url(../images/banner/del.gif) }
.OptionButton { width:16px;height:15px;background-image:url(../images/banner/option.gif) }
.QueryButton { width:16px;height:15px;background-image:url(../images/banner/query.gif) }
.SetUserButton { width:16px;height:15px;background-image:url(../images/banner/user.gif) }
.SetRightButton { width:16px;height:15px;background-image:url(../images/banner/userright.gif) }
.ChgPwdButton { width:16px;height:15px;background-image:url(../images/banner/pwd.gif) }
.SetRoleButton { width:16px;height:15px;background-image:url(../images/banner/role.gif) }
.ImportButton { width:16px;height:15px;background-image:url(../images/banner/import.gif) }
.PrintButton { width:16px;height:15px;background-image:url(../images/banner/print.gif) }
.TaskButton { width:16px;height:16px;background-image:url(../images/banner/task.gif) }

.kaoqinButton { width:16px;height:16px;background-image:url(../images/banner/kaoqin.gif) }
.transferButton { width:16px;height:16px;background-image:url(../images/banner/transfer.gif) }
.salaryButton { width:16px;height:16px;background-image:url(../images/banner/salary.gif) }
.workthingButton { width:16px;height:16px;background-image:url(../images/banner/workthing.gif) }
.performanceButton { width:16px;height:16px;background-image:url(../images/banner/performance.gif) }
.checkButton { width:16px;height:16px;background-image:url(../images/banner/check.gif) }
.workButton  { width:16px;height:16px;background-image:url(../images/banner/work.gif) }
.exitButton  { width:16px;height:16px;background-image:url(../images/banner/exit.gif) }
.backButton  { width:16px;height:16px;background-image:url(../images/banner/back.gif) }
.saveButton  { width:16px;height:16px;background-image:url(../images/banner/save.gif) }

.iconPwd  { width:16px;height:16px;background-image:url(../images/banner/pwd.gif)}
.iconHome  { width:16px;height:16px;background-image:url(../images/banner/home.gif)}
.iconCwd  { width:16px;height:16px;background-image:url(../images/banner/chgpwd.gif)}

.Maintenance { width:24px;height:24px;background-image:url(../images/banner/maintenance.gif) }
.ModifyTitle { width:24px;height:24px;background-image:url(../images/banner/modify.gif) }
.WorkBooks  { width:24px;height:24px;background-image:url(../images/banner/workbooks.gif) }


.Error { font-family:宋体, MS Sans Serif;font-size:9pt;
   color:#ff0000; }
   
.tInfo  { font-family:宋体, MS Sans Serif;font-size:9pt;font-weight:bold;color:"#B6972E" }
.tInfo2  { font-family:宋体, MS Sans Serif;font-size:9pt;font-weight:bold;color:"#003399" }

.GridBorder { border-top:solid 1px #6595d6;border-left:solid 1px #6595d6;border-right:solid 1px #6595d6;border-bottom:solid 1px #6595d6}

.grid-header a:active
{
 color: #222222;
 text-decoration: none;
}
.grid-header a:link
{
 color: #222222;
 text-decoration: none;
}
.grid-header a:visited
{
 color: #222222;
 text-decoration: none;
}
.grid-header a:hover
{
 color: #222222;
 text-decoration: none;
}
.grid-edit-column
{
 border-top: #696969 1px solid;
 border-bottom: #696969 1px solid;
 border-left: #696969 1px solid;
}
.grid-first-item
{
 border-top: #696969 1px solid;
 border-right: #696969 1px solid;
 border-bottom: #696969 1px solid;
 padding-right: 4px;
 padding-left: 4px;
 padding-bottom: 4px;
 padding-top: 4px;
 margin: 1px;
}
.grid-item
{
 border-right: #696969 1px solid;
 border-top: #696969 1px solid;
 border-left: #696969 1px double;
 border-bottom: #696969 1px solid;
 padding-right: 4px;
 padding-left: 4px;
 padding-bottom: 4px;
 padding-top: 4px;
 margin: 1px;
}
.grid-header
{
 border-bottom: #696969 1px solid;
 font-weight: bold;
 font-size: 11px;
 color: #696969;
 font-family: Verdana, Arial, Helvetica, sans-serif;
}
.grid-last-item
{
 border-top: #696969 1px solid;
 border-left: #696969 1px solid;
 border-bottom: #696969 1px solid;
 padding-right: 4px;
 padding-left: 4px;
 padding-bottom: 4px;
 padding-top: 4px;
 margin: 1px;
}

Input.AddButton
{
 background-color:Transparent;
 color:#264A54;
 background-image:url(../images/banner/);
 height:19;
 width:95;
 background-position:0 0;
 background-repeat:no-repeat;
 overflow:hidden;
 cursor:hand;
 font-family:Tahoma;
 border-style:none;
}

Input.QueryButton
{
 background-color:Transparent;
 color:#264A54;
 background-image:url(../images/banner/btn_query.gif);
 height:19;
 width:95;
 background-position:0 0;
 background-repeat:no-repeat;
 overflow:hidden;
 cursor:hand;
 font-family:Tahoma;
 border-style:none;
}

Input.ReportButton
{
 background-color:Transparent;
 color:#264A54;
 background-image:url(../images/banner/btn_check&accept.gif);
 height:19;
 width:95;
 background-position:0 0;
 background-repeat:no-repeat;
 overflow:hidden;
 cursor:hand;
 font-family:Tahoma;
 border-style:none;
}

Input.CheckAcceptButton
{
 background-color:Transparent;
 color:#264A54;
 background-image:url(../images/banner/btn_check&accept.gif);
 height:19;
 width:95;
 background-position:0 0;
 background-repeat:no-repeat;
 overflow:hidden;
 cursor:hand;
 font-family:Tahoma;
 border-style:none;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
WPF 中的 DataGrid 控件是一个强大的工具,可用于在应用程序中显示和编辑数据集。要创建漂亮DataGrid 样式,可以使用以下步骤: 1. 创建一个新的 WPF 应用程序项目。 2. 在项目中添加一个 DataGrid 控件。 3. 在 DataGrid 控件中设置 AutoGenerateColumns 属性为 False。这将使您能够手动指定列。 4. 添加所需的列。可以添加 TextBlock、ComboBox、CheckBox 等控件作为列的元素。 5. 为 DataGrid 添加样式。可以使用样式来更改 DataGrid 中每个单元格的外观,例如背景色、前景色、字体大小等。 6. 为 DataGrid 添加模板列。模板列允许您在 DataGrid 中嵌入自定义控件。 以下是一个简单的示例,演示如何创建具有漂亮样式DataGrid: ```xml <Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="450" Width="800"> <Grid> <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding}"> <DataGrid.Columns> <DataGridTemplateColumn Header="Photo"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <Image Source="{Binding Photo}" Width="50" Height="50"/> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*"/> <DataGridTextColumn Header="Age" Binding="{Binding Age}" Width="*"/> <DataGridTemplateColumn Header="Gender"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox ItemsSource="{Binding GenderOptions}" SelectedItem="{Binding Gender}" Width="100"/> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTemplateColumn Header="IsMarried"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <CheckBox IsChecked="{Binding IsMarried}"/> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> </DataGrid.Columns> <DataGrid.RowStyle> <Style TargetType="{x:Type DataGridRow}"> <Setter Property="Background" Value="#EEE"/> <Setter Property="Foreground" Value="#444"/> <Setter Property="FontSize" Value="16"/> </Style> </DataGrid.RowStyle> </DataGrid> </Grid> </Window> ``` 在这个示例中,我们添加了四列。第一列是一个模板列,显示每个人的照片。第二列是一个文本列,显示每个人的姓名。第三列也是一个文本列,显示每个人的年龄。第四列是一个模板列,允许用户选择每个人的性别。第五列是一个模板列,允许用户选择每个人是否已婚。 最后,我们为 DataGrid 添加了一个样式。这个样式定义了 DataGrid 中每个行的背景色、前景色和字体大小。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值