aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-06-18 14:49:53 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-06-18 14:49:53 +0300
commitf25823d812134a71b901562b72adfdb9185812a9 (patch)
tree36e4066677bca569cffb336896b8071a5212be46 /Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
parent647548244947e71aedb0770be0b12bd74bcf4c93 (diff)
downloadTango-f25823d812134a71b901562b72adfdb9185812a9.tar.gz
Tango-f25823d812134a71b901562b72adfdb9185812a9.zip
Fixed issue with RML in Machine Studio DB Module.
Implemented TouchTextBox. Made some modifications to ViewModel validation.
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/ViewModel.cs')
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/ViewModel.cs20
1 files changed, 16 insertions, 4 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs b/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
index 3b974d172..7d215cd06 100644
--- a/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs
@@ -9,6 +9,7 @@ using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using System.Windows.Controls;
using Tango.Core;
using Tango.Core.DI;
@@ -75,8 +76,6 @@ namespace Tango.SharedUI
/// <returns></returns>
protected bool Validate()
{
- OnValidating();
-
HasErrors = false;
_currentErrors.Clear();
@@ -87,24 +86,37 @@ namespace Tango.SharedUI
ValidationErrors.Clear();
+ OnValidating();
+
foreach (var prop in this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
{
foreach (var validation in prop.GetCustomAttributes<ValidationAttribute>())
{
if (!validation.IsValid(prop.GetValue(this)))
{
- HasErrors = true;
_currentErrors.Add(new KeyValuePair<string, string>(prop.Name, validation.ErrorMessage));
ValidationErrors.Add(validation.ErrorMessage);
- RaiseError(prop.Name);
}
}
+
+ HasErrors = _currentErrors.Count > 0;
+ RaiseError(prop.Name);
}
return !HasErrors;
}
/// <summary>
+ /// Inserts the specified property error (Use inside OnValidating).
+ /// </summary>
+ /// <param name="propName">Name of the property.</param>
+ /// <param name="error">The error.</param>
+ protected void InsertError(String propName, String error)
+ {
+ _currentErrors.Add(new KeyValuePair<string, string>(propName, error));
+ }
+
+ /// <summary>
/// Called before validating.
/// </summary>
protected virtual void OnValidating()