I would suggest using validation rules instead of code if at all possible. They will be automatically rerun for all fields any time any field value changes, so they will behave the way you're describing and won't have all the drawbacks of code.
If you absolutely have to use code, you can do something like this:
public void Kontonr_Validating(object sender, XmlValidatingEventArgs e)
{
ValidateKontonrKundenr();
}
public void Kundenr_Validating(object sender, XmlValidatingEventArgs e)
{
ValidateKontonrKundenr();
}
public void ValidateKontonrKundenr()
{
XPathNavigator kontonr = MainDataSource.CreateNavigator().SelectSingleNode("xpath", NamespaceManager);
XPathNavigator kundenr = MainDataSource.CreateNavigator().SelectSingleNode("xpath", NamespaceManager);
if(validate if the combo of fields Kontonr and Kundenr is not correct)
{
Errors.Add(kontonr, "kontonr", "Combo of the fields is not correct");
Errors.Add(kundenr, "kundenr", "Combo of the fields is not correct");
}
else
{
// This will throw an exception if no errors are currently set, but we can ignore it
try
{
Errors.Delete("kontonr");
Errors.Delete("kundenr");
}
catch {}
}
}