I implemented a sort of a wizard. With multiple windows. Each viewmodel of each window is a subclass of one base super class (also a viewmodel). In the first window, i fill up a property, which is in the base class. But in the next window, if i want to get that property, it is null. This is quite annoying and i really don’t know how this come.
This is my BaseViewModel:
public abstract class WijzigToetsBaseViewModel : INotifyPropertyChanged
{
#region Fields
Examination exam;
#endregion // Fields
#region Constructor
protected WijzigToetsBaseViewModel()
{
}
#endregion // Constructor
#region Properties
public Examination Examination
{
set { if(value != null)
exam = value; this.OnPropertyChanged("Examination");
}
get { return exam; }
}
So i the “shared” property is examination, in the first window , i fill this up by:
(viewmodel of the first window, implements model above)
public string Pad
{
get { return pad; }
set { pad = value;
OnPropertyChanged("Pad");
this.Examination = XmlConversionExamination.ReadExamination(value);
Naam = this.Examination.Name;
}
}
But then, if i want to get the property “examination” in the second window,it gives null:
public string Test
{
get {
return this.Examination.Name;
}
set { test = value;
OnPropertyChanged("Test");
}
}
(this is in second viewmodel, also implements base viewmodel.) so here this.Examination = null. This is kind of strange because i setted Examination property in the first window. Someone who has an idea?
Thanks
If you have two different ViewModels, then you thereby have two instances of the “base” ViewModel. So this is expected since Examination is an instance property.