WPF DataGrid行标题可见性错误

我使用DataGrid显示多个字段,其中一个是多行描述。 网格显示数据就好了,直到我尝试通过设置HeadersVisibility="Column"来隐藏标题行。 标题行消失但是当我滚动时,行标题重新出现一些随机行。

我已将其缩小到显示多行描述的列。 只要我离开这一栏,我就没有这个问题。 我试过用"\r\n""\n"分隔这些行,但都没有工作。 DataGrid是否支持多行文本字段?

下面是一张显示正在发生的事情的图片以及我用来创建网格的XAML。

DataGrid行标题错误图像

         

尝试设置RowHeaderWidth = 0而不是HeaderVisibility

在这种情况下,lvCurDocFields是父ListView。 这里的缺点是您需要为其他列设置硬宽度,然后其他列的总数是ConverterParameter。 如果你有一个垂直滚动条然后离开约20. GridView是一种痛苦但我喜欢的演示文稿,因为只读它比DataGrid更有效

  [ValueConversion(typeof(double), typeof(double))] public class WidthConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { // value is the total width available double otherWidth; try { otherWidth = System.Convert.ToDouble(parameter); } catch { otherWidth = 100; } if (otherWidth < 0) otherWidth = 0; double width = (double)value - otherWidth; if (width < 0) width = 0; return width; // columnsCount; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }