|
@@ -341,7 +341,7 @@ namespace InABox.DynamicGrid
|
|
|
deb.Click();
|
|
|
}
|
|
|
|
|
|
- private void OKButton_Click(object sender, RoutedEventArgs e)
|
|
|
+ public bool Validate()
|
|
|
{
|
|
|
var errors = OnValidateData?.Invoke(this, Items);
|
|
|
|
|
@@ -351,6 +351,15 @@ namespace InABox.DynamicGrid
|
|
|
string.Format("The following errors have been found with your data!\nPlease correct them and try again.\n\n- {0}",
|
|
|
string.Join("\n- ", errors)),
|
|
|
"Validation Error");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OKButton_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (!Validate())
|
|
|
+ {
|
|
|
return;
|
|
|
}
|
|
|
OnOK?.Invoke();
|
|
@@ -379,8 +388,13 @@ namespace InABox.DynamicGrid
|
|
|
//Close();
|
|
|
}
|
|
|
|
|
|
- public void SaveItem(CancelEventArgs e)
|
|
|
+ public void SaveItem(CancelEventArgs e, bool validate = true)
|
|
|
{
|
|
|
+ if(validate && !Validate())
|
|
|
+ {
|
|
|
+ e.Cancel = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
OnSaveItem?.Invoke(this, e);
|
|
|
}
|
|
|
|