我想在用户更改单元格的文本或内容时更改数据网格中单元格的颜色。
我正在使用 WPF 和 C#。
我有一个简单的数据网格:
<DataGrid x:Name="dataGrid1" Grid.RowSpan="2" Margin="5" ItemsSource="{Binding Source=Horreos}" KeyDown="dataGrid1_KeyDown" SelectedCellsChanged="dataGrid1_SelectedCellsChanged"> <DataGrid.Columns > </DataGrid.Columns> </DataGrid>
此事件:keydown 和 selectedcellschange 是更改我的颜色单元格的测试。在 .cs 中,我尝试更改 cel....但我失败了。
我需要一个内容变化时发布的事件
最佳答案
设置行为,最简单的方法是使用 Blend。我在我的博客文章中提供了一个针对数据网格的示例:Xaml: Adding Visibility Behaviors Using Blend to A DataGrid for WPF or Silverlight
关于c# - WPF 数据网格在文本更改时更改颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13251789/