Hi friends, I'm new here and I need a little help. I'm trying to use ListView to mount dynamic controls, that is, the controls appear only when I add an item in the list, however, this is not what is happening. If you add an item to the list when the page loads, the fields are shown, but if, at run time, adding another item to the list, the fields are not shown for this new item. The code is below. Please, can you tell me what I'm doing wrong? If it is not to use ListView in this case, which control is the best?
XAML:
VM:
public class SignUpVM : INotifyPropertyChanged
{
public ICommand CommandAddPhone { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName]string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private ObservableCollection<PhoneModel> phoneObsList;
public ObservableCollection<PhoneModel> PhoneObsList
{
get { return phoneObsList; }
set
{
phoneObsList = value;
}
}
public SignUpVM()
{
CommandAddPhone = new Command(async () =>
{
await OnAddPhoneCommand();
});
}
private async Task OnAddPhoneCommand()
{
if (PhoneObsList == null)
PhoneObsList = new ObservableCollection<PhoneModel>();
PhoneObsList.Add(new PhoneModel());
await Task.FromResult<object>(null);
}
}