I have a code like this:
public class ViewModel01
{
public ObservableCollection<MyType> MyProperty;
}
Public class ViewModel02
{
ObservableCollection<MyType> MyProperty;
Public ViewModel02()
{
ViewModel01 myViewModel = new ViewModel01;
MyProperty = myViewModel01.MyProperty;
}
}
My doubt is if in the constructor of the second view model, the object myViewModel is recollected by garbage collector or it still keep alive meanwhile ViewModel02 is still alive because I have a reference to the property of view model 01. Or perhaps the view model 01 is collected because really I have a reference to the ObservableCollection, not to the view model 01, so view model could be collected by garbage collector.
Also, I would like to know if there is some way to check if one object is collected or not. I am using visual studio 2019 community.
Thanks.