【发布时间】:2021-12-29 06:20:45
【问题描述】:
如果值无效,如何在自动生成的 DataGrid(来自 DataTable)中添加单元格验证并将单元格设置为红色?
这是我的数据网格:
<DataGrid Grid.Row="2"
Margin="5"
Background="Transparent"
MaxHeight="300"
MaxWidth="500"
ScrollViewer.CanContentScroll="True"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ItemsSource="{Binding DataTable}"
HeadersVisibility="None"
CellStyle="{StaticResource tableCellTheme}"
CanUserAddRows="False">
我也加了
<DataGrid.RowValidationRules>
<validation:DataGridValidation ValidationStep="UpdatedValue" />
</DataGrid.RowValidationRules>
但我不想评估整行,更重要的是,如果返回 false,我不知道如何将违规单元格设置为红色... 感谢您的帮助!
【问题讨论】:
标签: c# wpf validation xaml datagrid