验证Telerik可编辑的GridView行
问题描述:
我在WPF应用程序中使用Telerik RadGridView,它有两个可编辑列 - 数量和成本。我已经创建了一个模型来在网格中显示这些数据。验证Telerik可编辑的GridView行
e.g ::
[HasSelfValidation]
class Item
{
public int Quantity{get;set;}
public decimal Cost{get;set;}
[SelfValidation]
public void ValidateQuanity_Cost(...)
{
// if Quanity>0, Cost should also be greater than 0.
}
}
public ObservableCollection<Item> Items{get;set;}
<telerik:RadGridView ItemSource={Binding Items}.../>
我型项目的一个ObservableCollection绑定到GridView的Telerik的。 虽然验证完美,但我想突出显示 生成错误的行并显示工具提示。任何人都可以帮助实现这一点?
答
你可以让你Item
暴露出BackgroundColor
(类型Color
)和ToolTipText
(string
类型)属性,你可以在你的数据模板绑定。
答
使您的Item对象暴露“IsValid”属性,然后使用自定义类型转换器将其转换为背景色。同样的工具提示,但可能需要一个枚举的ErrorType属性。