Hi,
in your approach you can change your Model:
namespace DateTextBoxApp.Models
{
public class CustomerModel : INotifyPropertyChanged
{
private int _CustomerID;
public int CustomerID
{
get { return _CustomerID; }
set
{
if (value != _CustomerID)
{
_CustomerID = value;
OnPropertyChanged(nameof(CustomerID));
}
}
}
private string _FirstName;
public string FirstName
{
get { return _FirstName; }
set
{
if (value != _FirstName)
{
_FirstName = value;
OnPropertyChanged(nameof(FirstName));
}
}
}
private object _DateOfBirth;
public object DateOfBirth
{
get { return _DateOfBirth; }
set
{
if (value != _DateOfBirth)
{
_DateOfBirth = new DOB(value);
OnPropertyChanged(nameof(DateOfBirth));
}
}
}
//*********************************************************************************************************************************************************************************************************************88
//*********************************************************************************************************************************************************************************************************************88
//*********************************************************************************************************************************************************************************************************************88
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public class DOB
{
public DOB(object value)
{
var dateParts = value.ToString().Split('/');
Day = dateParts.Length > 0 ? dateParts[0] : null;
Month = dateParts.Length > 1 ? dateParts[1] : null;
Year = dateParts.Length > 2 ? dateParts[2] : null;
}
public string FullDate { get => this.ToString(); }
public string Day { get; set; }
public string Month { get; set; }
public string Year { get; set; }
public override string ToString()
{
return $"{Day}/{Month}/{Year}";
}
}
}
}
Result: