首页 > 其他分享 >在WPF中用DataGrid实现表格样式

在WPF中用DataGrid实现表格样式

时间:2022-11-07 17:34:30浏览次数:47  
标签:表格 样式 中用 DataGrid 关键 WPF

资源文件

定义颜色及样式


<SolidColorBrush x:Key="TextColorGeneral" Color="#a2a2a2" />


<Style TargetType="DataGridColumnHeader">
    <Setter Property="HorizontalContentAlignment" Value="Center" />
    <Setter Property="BorderBrush" Value="#a8a8a8" />
    <Setter Property="Background" Value="#f2f2f2" />
    <Setter Property="FontSize" Value="15" />
    <Setter Property="Padding" Value="5" />
    <Setter Property="Foreground" Value="{StaticResource TextColorGeneral}" />
    <Setter Property="BorderThickness" Value="0,0,1,1" /> // 关键
</Style>

设置dataGrid属性


<DataGrid
        Grid.Row="5"
        d:ItemsSource="{StaticResource testItems}"
        AutoGenerateColumns="False"
        BorderBrush="#a8a8a8"
        CanUserAddRows="False"
        CanUserReorderColumns="False"
        CanUserResizeColumns="False"
        HeadersVisibility="Column"
        ItemsSource="{Binding CalibrationItems}"
        SelectionMode="Single"
        SelectionUnit="Cell"
        Style="{StaticResource BaseStyle}"
        BorderThickness="1,1,0,0" // 关键
        HorizontalGridLinesBrush="#a8a8a8" // 关键
        VerticalGridLinesBrush="#a8a8a8"> // 关键
</DataGrid>

效果图

image

标签:表格,样式,中用,DataGrid,关键,WPF
From: https://www.cnblogs.com/baibaisheng/p/16866733.html

相关文章

  • vue表格滚动vue-seamless-scroll
    引入  npminstallvue-seamless-scroll--save  在找到main.js引入importscrollfrom'vue-seamless-scroll'Vue.use(scroll)主要代码<template>......
  • py爬虫数据到本地Excel表格
    效果图需要爬取的网页和内容程序目的:根据​​公众号文章​​中的内容,爬取文章的标题、发布时间、责任人署名、文章链接,将这个python程序打包成为exe文件,在运行exe文件时可以......
  • WPF 自定义控件 动画仪表盘控件 Gauge
    原文网址:https://blog.csdn.net/weixin_42850577/article/details/124008594WPF自制动画仪表盘控件Gauge  Xaml代码:<StyleTargetType="{x:Typectrl:ArcGauge......
  • 【WPF】ConfigurationManager连接sqlite数据库
     提供对客户端应用程序配置文件的访问。此类不能被继承。1、引用ConfigurationManager在Nuget引入ConfigurationManager。usingSystem.Configuration;  2、添......
  • Python实现寄存器表格生成寄存器rtl代码
    功能需求:通过约定好字段的寄存器表格生成寄存器代码语言要求:Python关键点:如何操作表格-通过openpyxl第三方库实现思路:读取表格,将表格内容以列表形式存储,在存储时,对寄存器......
  • 针对`elementui`table表格中的prop属性是个数组的处理方法
    表格<el-table:data="tableData"style="width:100%;margin-bottom:20px;"row-key="id"borderdefault-expand-all><el-table-columnprop="name"label=......
  • 【Vue】可编辑表格与三级联动下拉
    需求是给员工分配岗位,设计上是一人多岗的存在...单位—— 部门—— 岗位 这样的层级功能效果:因为员工可以在不同的单位下任职岗位,所以这个每一个岗位都是一个独立......
  • handsontable赋值加载表格后只显示部分单元格
    当行或者列太多的时候,handsontable为了加载速度。会只渲染部分数据。当页面有动作的时候才会再次渲染剩余数据。控制的相关属性为:viewportColumnRenderingOffset:200,//......
  • wpf
    目录学习之因学习资料学习坎坷MyApp.txt(7,4):errorCS0012:类型“Enum”在未引用的程序集中定义。必须添加对程序集“System.Runtime,Version=6.0.0.0,Culture=neutra......
  • 原生javascript点击获取table表格数据
    1.ajax获取List数据xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4&&xmlHttp.status==200){letreturnVal......