惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
S
SegmentFault 最新的问题
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
Jina AI
Jina AI
H
Help Net Security
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Vercel News
Vercel News
L
LangChain Blog
Recorded Future
Recorded Future
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
GbyAI
GbyAI
B
Blog RSS Feed
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
M
MIT News - Artificial intelligence
爱范儿
爱范儿
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Y
Y Combinator Blog
B
Blog
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
W
WeLiveSecurity
MongoDB | Blog
MongoDB | Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
The Cloudflare Blog
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
有赞技术团队
有赞技术团队
D
DataBreaches.Net
博客园 - 【当耐特】
T
Troy Hunt's Blog
V
Visual Studio Blog
V2EX - 技术
V2EX - 技术
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google Online Security Blog
Google Online Security Blog
The GitHub Blog
The GitHub Blog

博客园 - 水色天空

用docfx生成c#项目API的简洁教程 wpf datagrid鼠标穿透 OxyPloot设置X轴时间DateTimeAxis WPF中MVVM模式下ComboBox绑定,无法更新selectedItem的解决方案 WPF设置DatePicker日期格式之卡Bug大法 WPF程序自动重启 InstallShield打包.net项目无法包含数据库、配置文件等 handycontrol中NumericUpDown无法显示自定义错误提示的解决办法 Chapter 2 - Sockets and Patterns【选译,哈哈】 Part 9 High-Water Marks Chapter 2 - Sockets and Patterns【选译,哈哈】 Part 9 Missing Message Problem Solver Chapter 2 - Sockets and Patterns【选译,哈哈】 Part 9 Zero-Copy Chapter 2 - Sockets and Patterns【选译,哈哈】 Part 8 Node Coordination Chapter 2 - Sockets and Patterns【选译,哈哈】 Part 6 Multithreading with ZeroMQ Chapter 2 - Sockets and Patterns【选译,哈哈】 Part 7 Signaling Between Threads (PAIR Sockets) Chapter 2 - Sockets and Patterns【选译,哈哈】 Part 5 Handling Interrupt Signals WPF绑定RadioButton的标准做法 解决.net reactor加密后的dll,在其它电脑无法运行的问题 函数返回值的一些规则 Chapter 2 - Sockets and Patterns【选译,哈哈】 Part 4 Handling Errors and ETERM
DataGrid代码生成列居中问题
水色天空 · 2021-10-21 · via 博客园 - 水色天空

样式:

            <Style x:Key="contentCenterStyle" TargetType="{x:Type TextBlock}">
                <Setter Property="HorizontalAlignment" Value="Center"/>
            </Style>

后台添加列的代码:

new DataGridTextColumn() { Header = name.Trim('*'), Binding = new System.Windows.Data.Binding(name + i.ToString()), MinWidth=average, ElementStyle= (Style)grid.FindResource("contentCenterStyle") }

其中的grid是DataGrid的引用,只要继承自FrameworkElement的都可以,用的是FindResource(),方法,然后记得转换成Style类型。