-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathOrderEditForm.xaml.cs
More file actions
31 lines (26 loc) · 953 Bytes
/
OrderEditForm.xaml.cs
File metadata and controls
31 lines (26 loc) · 953 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
31
using DevExpress.Maui.Core;
namespace EditForm;
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_ValidateProperty(object sender, DevExpress.Maui.DataForm.DataFormPropertyValidationEventArgs e) {
if (e.PropertyName == "Quantity" && (decimal)e.NewValue <= 0) {
e.ErrorText = "The value must be positive.";
e.HasError = true;
}
else if (e.PropertyName == "Date" && (DateTime)e.NewValue > DateTime.Now.Date) {
e.ErrorText = "The date value cannot be in the future.";
e.HasError = true;
}
}
}