-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathOrderEditForm.xaml.cs
More file actions
30 lines (26 loc) · 921 Bytes
/
OrderEditForm.xaml.cs
File metadata and controls
30 lines (26 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using DevExpress.Maui.Core;
namespace ValidateFormEvent;
public partial class OrderEditForm : ContentPage
{
DetailEditFormViewModel ViewModel => (DetailEditFormViewModel)BindingContext;
public OrderEditForm()
{
InitializeComponent();
}
private void ToolbarItem_Clicked(object sender, EventArgs e) {
if (!this.dataFormView.Validate())
return;
this.dataFormView.Commit();
ViewModel.Save();
}
private void dataFormView_ValidateForm(object sender, DevExpress.Maui.DataForm.DataFormValidationEventArgs e) {
if ((decimal)e.NewValues["Quantity"] <= 0) {
e.Errors.Add("Quantity", "The value must be positive.");
e.HasErrors = true;
}
if ((DateTime)e.NewValues["Date"] > DateTime.Now.Date) {
e.Errors.Add("Date", "The date value cannot be in the future.");
e.HasErrors = true;
}
}
}