From e16385118f59d10f803f11eaef6c8b9780491794 Mon Sep 17 00:00:00 2001 From: Jeyasri Murugan Date: Fri, 22 Dec 2023 12:32:09 +0530 Subject: [PATCH] Property changed added --- DataFormMAUI/Model/ContactFormModel.cs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/DataFormMAUI/Model/ContactFormModel.cs b/DataFormMAUI/Model/ContactFormModel.cs index 6cffcb2..3f2f322 100644 --- a/DataFormMAUI/Model/ContactFormModel.cs +++ b/DataFormMAUI/Model/ContactFormModel.cs @@ -1,10 +1,11 @@ using SQLite; using Syncfusion.Maui.DataForm; +using System.ComponentModel; using System.ComponentModel.DataAnnotations; namespace DataFormMAUI { - public class ContactFormModel + public class ContactFormModel : INotifyPropertyChanged { [PrimaryKey, AutoIncrement] [Display(AutoGenerateField = false)] @@ -38,6 +39,7 @@ public string Mobile { mobile = new string(value.Where(c => Char.IsLetterOrDigit(c)).ToArray()); } + RaisePropertyChanged(nameof(Mobile)); if (mobile.Length == 10) this.MaskedMobileText = string.Format("({0}) {1}-{2}", mobile.Substring(0, 3), mobile.Substring(3, 3), mobile.Substring(6)); } @@ -60,7 +62,25 @@ public string Mobile public string Email { get; set; } + private string maskedMobileText; + [Display(AutoGenerateField = false)] - public string MaskedMobileText { get; set; } + public string MaskedMobileText + { + get { return maskedMobileText; } + set + { + this.maskedMobileText = value; + RaisePropertyChanged(nameof(MaskedMobileText)); + } + } + + public event PropertyChangedEventHandler PropertyChanged; + + private void RaisePropertyChanged(string name) + { + if (PropertyChanged != null) + this.PropertyChanged(this, new PropertyChangedEventArgs(name)); + } } }