c# – 更改WPF Datagrid行颜色

c# – 更改WPF Datagrid行颜色,第1张

概述我有一个充满ObserverableCollection的 WPF数据网格. 现在我想根据程序启动时的行内容以及运行时是否有变化来为行着色. System.Windows.Controls.DataGrid areaDataGrid = ...;ObservableCollection<Area> areas;//adding items to areas collectionareaDat 我有一个充满ObserverableCollection的 WPF数据网格.

现在我想根据程序启动时的行内容以及运行时是否有变化来为行着色.

System.windows.Controls.DataGrID areaDataGrID = ...;ObservableCollection<Area> areas;//adding items to areas collectionareaDataGrID.ItemsSource = areas;areaDataGrID.Rows  <-- Property not available. how to access rows here?CollectionVIEw myCollectionVIEw = (CollectionVIEw)CollectionVIEwSource.Getdefaultview(areaDataGrID.Items);((INotifyCollectionChanged)myCollectionVIEw).CollectionChanged += new NotifyCollectionChangedEventHandler(areaDataGrID_Changed);...voID areaDataGrID_Changed(object sender,NotifyCollectionChangedEventArgs e){    //how to access changed row here?}

如何在启动和运行时访问行?

解决方法 使用 RowStyle.您可以使用 Triggers有条件地更改颜色,或者只是将其绑定到项目的Brush属性并分别更改该属性. 总结

以上是内存溢出为你收集整理的c# – 更改WPF Datagrid行颜色全部内容,希望文章能够帮你解决c# – 更改WPF Datagrid行颜色所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1239593.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-06
下一篇2022-06-06

发表评论

登录后才能评论

评论列表(0条)

    保存