I have the following situation:
I make the instance of an observable property in the constructor:
public ObservableCollection<Model.OSModel> _os { get; private set; }
public EditorServicosViewModel()
{
OS = new ObservableCollection<Model.OSModel>();
}
When I add an item to the collection within a method:
public void OnTabClicked(ListaServicosTab listaServicosTab)
{
OS.Add(listaServicosTab.vm.OSItem);
OnPropertyChanged("OS");
}
It does not bind to TextBlock
.
But if I make the instance inside método
:
public void OnTabClicked(ListaServicosTab listaServicosTab)
{
OS = new ObservableCollection<Model.OSModel>();
OS.Add(listaServicosTab.vm.OS);
OnPropertyChanged("OS");
}
It does the binding.
Someone can tell me the reason for this, because I have already done a lot of juggling and I can not solve it, because I do not want the instance inside the method but in the constructor.