3
I have the following situation:
I make the instance of a property observable in the constructor:
public ObservableCollection<Model.OSModel> _os { get; private set; }
public EditorServicosViewModel()
{
OS = new ObservableCollection<Model.OSModel>();
}
When adding an item to the collection within a method:
public void OnTabClicked(ListaServicosTab listaServicosTab)
{
OS.Add(listaServicosTab.vm.OSItem);
OnPropertyChanged("OS");
}
He doesn’t connect with the TextBlock
.
But if I do the instance inside the método
:
public void OnTabClicked(ListaServicosTab listaServicosTab)
{
OS = new ObservableCollection<Model.OSModel>();
OS.Add(listaServicosTab.vm.OS);
OnPropertyChanged("OS");
}
He does the Binding.
Someone can tell me the reason for this, because I have done numerous juggling and I can not solve, because I do not want the instance within the method but in the constructor.
Review the property statement There’s something wrong with this
public ObservableCollection<Model.OSModel> _os; { get; private set; }
– ramaral
Won’t be
public ObservableCollection<Model.OSModel> OS { get; private set; }
?– ramaral