是否有使用WPF ValidationRules验证在同一个窗体上的另一个数据网格与数据更新的领域呢?验证一个WPF Datagrid的防止数据从另一个Datagrid的
我的页面看起来是这样的:
Ranges
Min Max
1 10
Rank
5
所以在这种情况下,排名的更新,我需要确保它是在另一个DataGrid中rangea的最小值和最大值之间。 我使用这个模式来验证从网格数据,但是当我需要通过它的数据从另一个电网不工作:
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
EF.Rank rank = (value as BindingGroup).Items[0] as EF.Rank;
//Need to Access the Ranges list from another datagrid on the same page to validate the the rank that was entered is between the min and max which can be adjusted.
}
从微软官方WPF课程材料:'ValidationRules'仅是用作简单验证(例如必填字段,数字格式等)。如果你需要高级/复杂的业务规则验证,你应该实现'IDataErrorInfo'或者创建你自己的验证机制(这就是我所做的,它像一个魅力) –