I have ViewModelBase
with a derived DerivedViewModel
ViewModelBase
has DoSomething()
which accesses AProperty
DerivedViewModel also uses DoSomething()
but it needs to access a different object.
The reason behind this is that the ViewModel is used on a screen, as well as in a Dialog. When it is in a screen, it needs to access a particular entity, but when in a dialog, it needs to access a different entity.
Here it is, simplified, in code. If you run it, they both return A, instead of A, then B. So the question is, how to return A, then B?
class Program
{
static void Main(string[] args)
{
ViewModelBase bc = new ViewModelBase();
bc.DoSomething(); Prints A
DerivedViewModel dr = new DerivedViewModel();
dr.DoSomething(); Prints A, would like it to print B.
}
}
public class ViewModelBase {
private string _aProperty = "A";
public string AProperty {
get {
return _aProperty;
}
}
public void DoSomething() {
Console.WriteLine(AProperty);
}
}
public class DerivedViewModel : ViewModelBase {
private string _bProperty = "B";
public string AProperty {
get { return _bProperty; }
}