我正在尝试使用以下命令检索 DataGrid 中具有特定背景颜色/画笔的列列表:
Dim OutputCols As New List(Of DataGridColumn)
OutputCols = datagrid_Output.Columns.Where(Function(a) Not (a.CellStyle Is Nothing) AndAlso a.GetValue(BackgroundProperty) Is GridOutputsColor).ToList
但是,这不起作用,我发现 GetValue(BackgroundProperty) 正在返回空白值。但是,如果我这样做,我会得到 SetterBase 对象,而不是我想要的 Setter(s):
Dim OutputCols As New List(Of DataGridColumn)
OutputCols = datagrid_Output.Columns.Where(Function(a) Not (a.CellStyle Is Nothing) AndAlso a.CellStyle.Setters.First(Function(b) b.property Is BackgroundProperty).value Is GridOutputsColor).ToList
...它不起作用,因为 Function(b) 返回 SetterBase 对象而不是每个 Setter。