且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用数据绑定在WPF中设置列表视图项的背景颜色?

更新时间:2023-01-25 17:51:21

尝试样式属性。

可以将此代码添加到 ListView 中,然后应设置 ListViewItems Brush 颜色。

One can add this code to the ListView and then it should set the background of the ListViewItems to the Brush color.

<ListView>
   <ListView.ItemContainerStyle>
      <Style TargetType="{x:Type ListViewItem}">
           <Setter Property="Background" Value="{Binding Brush}" />
      </Style>
   </ListView.ItemContainerStyle>

   ...

</ListView>