【发布时间】:2011-11-22 04:41:29
【问题描述】:
我有一个 WPF DataGrid,它显示实现 IDataErrorInfo 的类型。正如预期的那样,当验证失败时,行获得红色感叹号,无效单元格获得红色突出显示。
这一切都很好;但是,我希望验证错误消息显示在无效单元格的工具提示中,以便用户有一些错误指示。我目前有:
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={RelativeSource Self},
Path=(Validation.Errors[0].ErrorContent}"/>
</Style>
</DataGrid.CellStyle>
这种方法适用于TextBox,但不适用于DataGridCell。有什么区别?
【问题讨论】: