我正在尝试使用 JScript.Net 更改 ListView 上一行的颜色。我正在编写一个我无法访问代码的应用程序的脚本,但我可以添加修改 ListView 的脚本。
我正在尝试的是:
this.listView = controller.RenderEngine.ListControl.ListView;
this.listView.Items[0].UseItemStyleForSubItems = false;
this.listView.Items[0].SubItems[1].ForeColor = new System.Windows.Media.SolidColorBrush(Colors.Yellow);
或者
this.rows = IList(listView.ItemsSource); // Use the ItemsSource to get data
rows[1].Forecolor = new System.Windows.Media.SolidColorBrush(Colors.Yellow);
this.listView.Items(0).FonttWeight = System.Windows.Controls.FontWeights.UltraBold;
这一切都在起作用。
但是,我可以使用以下说明使其工作:
listViewItem = listView.ItemContainerGenerator.ContainerFromIndex(i);
listViewItem.Background = color;
但是使用此解决方案,如果 ListView 上发生滚动或焦点更改,则绘制行上的更改将消失。
有任何想法吗?。
谢谢你的时间。