I have a switch. When I click that switch, I catch that false or true value. But when I catch true I want to disable or do something similar with my department entry, but I don't have "handle" to that component. How to do it in MVVM pattern, how to get a "handle" to that component? Because in "behind code" it's so easy. Sorry for my bad english.
internal class RegisterPageViewModel : INotifyPropertyChanged
{
private string _name;
private string _switchValue;
public string Name
{
get => _name;
set
{
_name = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Name)));
}
}
public string SwitchValue
{
get => _switchValue;
set => _switchValue = value;
}
public string MiddleName { get; set; }
public string Surname { get; set; }
public string Email { get; set; }
public string PhoneNumber { get; set; }
public string DepartmentCode { get; set; }
public ICommand ImAnEmployeeCommand { get; }
public RegisterPageViewModel()
{
ImAnEmployeeCommand = new Command<bool>(AmAnEmployeeExecute);
}
private void AmAnEmployeeExecute(bool switchValue)
{
if (switchValue)
{
App.Current.MainPage.DisplayAlert("sds", switchValue.ToString(), "dsad");
}
}
public event PropertyChangedEventHandler PropertyChanged;
}