本文整理汇总了C#中System.Windows.Data.BindingGroup.Name属性的典型用法代码示例。如果您正苦于以下问题:C# BindingGroup.Name属性的具体用法?C# BindingGroup.Name怎么用?C# BindingGroup.Name使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Data.BindingGroup
的用法示例。
在下文中一共展示了BindingGroup.Name属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Type1
public class Type1
{
public string PropertyA { get; set; }
public Type1()
{
PropertyA = "Default Value";
}
}
public class Type2
{
public string PropertyB { get; set; }
public Type2()
{
}
}
public class BindingGroupValidationRule : ValidationRule
{
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
{
BindingGroup bg = value as BindingGroup;
Type1 object1 = null;
Type2 object2 = null;
foreach (object item in bg.Items)
{
if (item is Type1)
{
object1 = item as Type1;
}
if (item is Type2)
{
object2 = item as Type2;
}
}
if (object1 == null || object2 == null)
{
return new ValidationResult(false, "BindingGroup did not find source object.");
}
string string1 = bg.GetValue(object1, "PropertyA") as string;
string string2 = bg.GetValue(object2, "PropertyB") as string;
if (string1 != string2)
{
return new ValidationResult(false, "The two strings must be identical.");
}
return ValidationResult.ValidResult;
}
}