You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.9 KiB
75 lines
1.9 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MVVMSample.Model
|
|
{
|
|
internal class ViewModelMain : NotifierMain
|
|
{
|
|
private string _firstName;
|
|
private string _lastName;
|
|
private string _fullName;
|
|
private string _birthday;
|
|
|
|
private bool _isBirthdayError = false;
|
|
|
|
public string FirstName
|
|
{
|
|
get { return _firstName; }
|
|
set
|
|
{
|
|
_firstName = value;
|
|
_fullName = $"{_lastName} {_firstName}";
|
|
NotifyChanged("FirstName", "FullName");
|
|
}
|
|
}
|
|
|
|
public string LastName
|
|
{
|
|
get { return _lastName; }
|
|
set
|
|
{
|
|
_lastName = value;
|
|
_fullName = $"{_lastName} {_firstName}";
|
|
NotifyChanged("LastName", "FullName");
|
|
}
|
|
}
|
|
|
|
public string FullName { get { return _fullName; } }
|
|
|
|
public string Birthday
|
|
{
|
|
get { return _birthday; }
|
|
set
|
|
{
|
|
if (Regex.IsMatch(value, "^[0-9]*$"))
|
|
{
|
|
_birthday = value;
|
|
_isBirthdayError = false;
|
|
}
|
|
else
|
|
{
|
|
_birthday = value;
|
|
_isBirthdayError = true;
|
|
}
|
|
NotifyChanged("Birthday", "BirthdayError", "BirthdayErrorMessage");
|
|
}
|
|
}
|
|
|
|
public bool BirthdayError { get { return _isBirthdayError; } }
|
|
|
|
public string BirthdayErrorMessage
|
|
{
|
|
get
|
|
{
|
|
if (!_isBirthdayError)
|
|
return $"Birthday: {_birthday}";
|
|
else
|
|
return $"Please input the number value ({Birthday})";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|