Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何强制我的 WPF GridView 列宽度自动调整以适应其内容?
将每列的宽度设置为Double.NaN。但是,首先将其设置为除此之外的任何内容。
Double.NaN
foreach (GridViewColumn c in MyGridView.Columns) { c.Width = c.ActualWidth; c.Width = Double.NaN; }